sanity-io / sanity-plugin-internationalized-array

A plugin to register array fields with a custom input component to store field values in multiple languages, queryable by using the language ID as an array `_key`.
MIT License
43 stars 11 forks source link

Toggle or hide translation fields #42

Open ohp-inmeta opened 1 year ago

ohp-inmeta commented 1 year ago

Hi, and thanks for a great plugin!

I was wondering if there is any way to implement some sort of toggle or expand/collapse view for translations other that the default language? On content types with a lot of fields, it quickly gets a bit cluttered when all translations for all fields are displayed simultaneously, especially if there are many translations. To be able to expand/show a translation for a field, edit it, then close/hide it for instance, would be great.

SimeonGriggs commented 1 year ago

You can get a behavior close to this by combining this plugin with the @sanity/language-filter plugin

keboye commented 1 year ago

Tried that just now, and while the input fields do hide, so filtering seems to work, the "container field" itself doesn't so it ends up taking just as much vertical space. Multiply that by 10 languages for larger productions and it becomes unusable due to all the scrolling required.

Example: image

keboye commented 1 year ago

Would it be possible to hide the fields (FI_FI for instance, not just the input field itself) to reduce scrolling/clutter when using language filtering?

Would it be possible to add an option to hide the "remove language"-icon? In production it's way to easy to remove when tabbing (mass production use case).

Also, has anyone tried this in actual use case? I'm seeing/benchmarking >0.5-1s input lag pegging a CPU thread at 100% on a 5950X in production (not dev) when using 10 languages, for a schema with just 10 string fields (which gets multiplied by amount of languages). The lag is lower the fewer fields there are. I've worked around this before on custom input components by using onBlur vs onChange.