sanity icon indicating copy to clipboard operation
sanity copied to clipboard

@sanity/language-filter (v.2) not showing switcher

Open fabien opened this issue 3 years ago • 3 comments
trafficstars

I have used @sanity/language-filter on a project in the past, but it doesn't appear to be working in a new v.2 project today, running all the latest versions of Studio.

I've followed the official instructions, implemented the part etc. but the Studio UI integration in the document pane header simply doesn't show. I'm 100% positive the filterField function is being called, non-default language fields are hidden and logging to the console confirms that it's working.

Note that I have tried with no documentTypes as well as with an explicit array of types.

Steps to reproduce the behavior:

Follow the instructions: https://www.npmjs.com/package/@sanity/language-filter

Expected behavior

To show the widget/switcher as expected and as shown in the animated gif.

Screenshots

image

Which versions of Sanity are you using?

@sanity/cli 2.30.2 (up to date) @sanity/base 2.30.1 (up to date) @sanity/core 2.30.2 (up to date) @sanity/default-layout 2.30.1 (up to date) @sanity/default-login 2.30.1 (up to date) @sanity/desk-tool 2.30.1 (up to date) @sanity/eslint-config-studio 2.0.0 (up to date) @sanity/language-filter 2.29.8 (up to date) @sanity/vision 2.30.1 (up to date)

What operating system are you using?

Mac/Chrome

Which versions of Node.js / npm are you running?

8.12.1 v18.4.0

fabien avatar Jul 09 '22 09:07 fabien

@LiamMartens perhaps you can confirm that there might be an issue? Looks like the implementation was changed to handle a shouldShow flag: https://github.com/sanity-io/sanity/commit/75e75c5cd9a127483f69148e5211211cabe09def

fabien avatar Jul 09 '22 09:07 fabien

Turns out that the implementation doesn't conform to the original config options documentation:

documentTypes (optional) is an array of strings where each entry must match a name from your document schemas. If defined, this property will be used to conditionally show the language filter on specific document schema types. If undefined, the language filter will show on all document schema types.

In my opinion, the documentation is correct, shouldShow should return true when documentTypes is empty or not given at all. It's supposed to be optional so it can be shown without an explicit list of types.

In other words, https://github.com/sanity-io/sanity/commit/75e75c5cd9a127483f69148e5211211cabe09def is a regression.

fabien avatar Jul 09 '22 09:07 fabien

On a side-note, it's currently not possible to deselect the default languages. It would have been helpful to be able to toggle the default off, while falling back to the default if no language has been selected at all. Currently it's either: show default AND selected language(s), or: in some cases no language will be selected at all.

fabien avatar Jul 12 '22 10:07 fabien

Hi!

We are currently working on improving our workflows and follow-up on our open GitHub repository. In that work, we have decided to close most issues older than the release of Sanity Studio v3.

We value your feedback, so if this issue is still important to you and relevant for Sanity Studio v3, please search for relevant open issues. If you can’t find any, open a new one and link to relevant comments in this thread. For questions about how to do something, please post them in the [slack

kmelve avatar Jan 11 '23 19:01 kmelve