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

Internationalized Array String in objects not editable #37

Closed
appfr3d opened this issue Aug 2, 2023 · 4 comments · Fixed by #40
Closed

Internationalized Array String in objects not editable #37

appfr3d opened this issue Aug 2, 2023 · 4 comments · Fixed by #40

Comments

@appfr3d
Copy link

appfr3d commented Aug 2, 2023

I have a document called Menu, and which among other fields has an array of a custom menuItem object. In the menuItem I have defined the title field as an internationalizedArrayString like so:

    defineField({
      name: 'title',
      title: 'Title',
      type: 'internationalizedArrayString',
    }),

When trying to create new or edit menuItems, it is not possible to add any translations.

image

In my defineConfig I have this:

    internationalizedArray({
      languages: [
          {id: 'nb', title: 'Norwegian (Bokmål)'},
          {id: 'nn', title: 'Norwegian (Nynorsk)'},
          {id: 'en', title: 'English'},
      ],
      defaultLanguages: ['nb'],
      fieldTypes: ['string', 'url', 'slug'],
      buttonAddAll: true,
      buttonLocations: ['field'],
    }),

Any obvious reason why this is happening?

@selbekk
Copy link

selbekk commented Aug 2, 2023

Looks like if you add an internationalizedArrayString field type to the document itself, it works as expected. This is because of this check, which doesn't check for nested arrays of objects.

It looks like the flattenSchema doesn't support iterating through arrays of objects like we do here.

@bobinska-dev
Copy link

bobinska-dev commented Aug 2, 2023

Hello everyone,
We are looking into this, but as a workaround, you can add a hidden internationalizedArrayString field at the document level, and then it works in the nested structure as well.
Not the best solution but a quick fix for now.

@selbekk
Copy link

selbekk commented Aug 2, 2023

Yep, that's what we did. Hopefully we can avoid it in the future :-)

@DmitriyMaltsevTakeda
Copy link

DmitriyMaltsevTakeda commented Nov 2, 2023

I'm having the same problem.

In my case, there is the following document hierarchy:
document (type Foo) -> array of objects (type Bar) -> array of objects (type Baz)

Objects of type Baz have several fields of type internationalizedArrayString, and they are not editable (same problem as OP had).

If I add a hidden field of type internationalizedArrayString to Foo as suggested by @selbekk and @bobinska-dev, it works.
If I do the same for Bar only, the error still reproduces.

I briefly looked at the fix, and it seems that it can handle only the case with one level of nesting in root documents, but I may be wrong.

Is there any way to fix that without the hidden internationalizedArrayString field workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants