Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of properties on fields of an i18n object or document won't work #94

Open
hrisng opened this issue Nov 3, 2021 · 1 comment
Open
Labels
bug Something isn't working

Comments

@hrisng
Copy link

hrisng commented Nov 3, 2021

Description: Properties that requires coordination from Sanity Studio like validation, hidden, initialValue, fieldsets will stop working if I set the i18n option to true on a document or object. This will only affect the direct child fields of said document or object. Fields one level deeper (inside another child object) will have their normal behaviour back.

Example:

  {
      name: 'localizedContent',
      type: 'object',
      title: 'Nội dung đa ngôn ngữ',
      options: { i18n: true },
      fields: [
        {
          name: 'hasCallToAction',
          type: 'boolean',
          title: 'Hiển thị Call To Action',
          initialValue: false,
        },
        {
          name: 'callToAction',
          type: 'object',
          title: 'Call To Action',
          hidden: true,
          options: {
            collasible: true,
            collapsed: true,
          },
          fields: [
            { title: 'Text thể hiện', name: 'displayText', type: 'string' },
          ],
        },

In the above snippet, initialValue on hasCallToAction will not be set, and callToAction field is not hidden. However, things specified in options like collapsible will still work correctly.

Expected behaviour:
These properties are crucial and the plugin should not interfere with that.

What I found:
An i18n object in the above case will normally have this shape:

localizedContent: {
  vi_VN: {},
  en_EN: {}
}

Now what happen when I set initialValue on hasCallToAction is that it gonna get this shape:

localizedContent: {
  vi_VN: {},
  en_EN: {},
  hasCallToAction: false <------- It get populated here instead of inside the appropriate locale
}

^ Understandably, because of this, Sanity Studio is not being able to correctly populate the initialValue in the input. Somehow it's the same case with hidden , validation , fieldset and the like.

Environment:
Sanity: 2.21.6
sanity-plugin-intl-input: 5.5.0

@LiamMartens LiamMartens added the bug Something isn't working label Nov 4, 2021
@LiamMartens
Copy link
Owner

@hrisng I am looking at this - it's not the easiest to fix as it concerns internal Sanity mechanics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants