sanity-io / language-filter

A Sanity plugin that supports filtering localized fields by language
MIT License
17 stars 1 forks source link

Fields not filtered if `documentTypes` or `languageFilter` not configured #63

Open james-camilleri opened 3 months ago

james-camilleri commented 3 months ago

Describe the bug

The documentation seems to indicate that not setting the documentTypes field on the plugin configuration will show the filter on all schema types: https://github.com/sanity-io/language-filter/blob/d2ea195f00ca92b54b3ca70fc0e739de1494b17e/README.md?plain=1#L84

The most recent version of this plugin (I haven't yet tested with earlier versions) seems to fail to function if neither of the documentTypes or languageFilter options are set. The filter is displayed on the top of the page, but selecting items does nothing and the filterField function isn't called at all. Adding the required schema types to the documentTypes config option solves this, and the filtering functionality works again.

Filter active, with no documentTypes set, does nothing: image

Enabling the documentTypes option (or setting the languageFilter on the schema in question) causes the filtering to kick in: image

I'm not sure if this is an actual issue, or just a case of outdated documentation.

To Reproduce

Steps to reproduce the behavior:

  1. Set up the plugin as described in the README. Do not set a languageFilter array in the config.
  2. Try and filter fields - this will fail.
  3. Set the languageFilter config option.
  4. Filtering will work on the configured schema types.

Expected behavior

Filtering of localised fields will work on all schemas if no languageFilter is set.

Which versions of Sanity are you using?

@sanity/cli (global)       3.36.4 (up to date)
@sanity/cli                3.36.4 (up to date)
@sanity/components         2.14.0 (up to date)
@sanity/google-maps-input   3.0.2 (up to date)
@sanity/language-filter     3.2.2 (up to date)
@sanity/table               1.1.2 (up to date)
@sanity/vision             3.36.4 (up to date)
sanity                     3.36.4 (up to date)

What operating system are you using? Windows.

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

 npm -v && node -v
10.5.0
v21.7.2