-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
[Package] DataViews/packages/dataviews/packages/dataviews[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
When an array field (like categories: ['Space', 'NASA']) from the test fixtures has enableGlobalSearch: true, the global search functionality throws a TypeError because the normalizeSearchInput function expects a string but receives an array.
Expected behavior: Global search should work with array fields, matching search terms against array values (e.g., searching "NASA" should match items with "NASA" in their categories array).
Current behavior: Throws TypeError: input.trim is not a function when attempting to search with array fields enabled for global search.
Step-by-step reproduction instructions
- Create a dataview with array field data:
const data = [
{ title: 'Apollo', categories: ['Space', 'NASA'] },
{ title: 'NASA', categories: ['NASA'] }
];
- Configure fields with enableGlobalSearch: true on the array field:
const fields = [
{ id: 'title', enableGlobalSearch: true },
{ id: 'categories', type: 'array', enableGlobalSearch: true }
];
- Perform a global search:
filterSortAndPaginate(data, { search: 'NASA' }, fields);
- Result: TypeError: input.trim is not a function is thrown
Screenshots, screen recording, code snippet
this patch shows the current behaviour and what should happen (skipped)
array-field-search-bug-test.patch
Environment info
GB trunk: c2842ff
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Package] DataViews/packages/dataviews/packages/dataviews[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended