From 42b44fe90afd9a42e1a62ba0f41d3adc3bde80c5 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Tue, 19 Nov 2024 10:46:28 -0600 Subject: [PATCH 1/2] clear filter value after an action is chosen from MultiSelection's option list. --- CHANGELOG.md | 1 + lib/MultiSelection/MultiSelection.js | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 104c9ac7b..0e435b896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Wrap `` in full-width div. Refs STCOM-1332. * Assign ``'s exit key handler to Modal's element rather than `document`. refs STCOM-1382. * Wrap ``'s render output in `` to facilitate ease with overlay components. Refs STCOM-1384. +* Clear filter value after an action chosen from `MultiSelection` menu. Refs STCOM-1385. ## [12.2.0](https://github.com/folio-org/stripes-components/tree/v12.2.0) (2024-10-11) [Full Changelog](https://github.com/folio-org/stripes-components/compare/v12.1.0...v12.2.0) diff --git a/lib/MultiSelection/MultiSelection.js b/lib/MultiSelection/MultiSelection.js index 4b3d4d90d..a173d03d8 100644 --- a/lib/MultiSelection/MultiSelection.js +++ b/lib/MultiSelection/MultiSelection.js @@ -272,6 +272,7 @@ const MultiSelection = ({ selectedItems, reset }); + setFilterValue(''); return { isOpen: false, // keep the menu open after selection. highlightedIndex, // don't move highlight cursor back to top of list on selection. From e197711fc3db862c5e3bb684cd8fdf90f2360410 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Thu, 21 Nov 2024 10:40:28 -0600 Subject: [PATCH 2/2] add tests for removed filter value, updated comment --- lib/MultiSelection/MultiSelection.js | 3 +-- lib/MultiSelection/tests/MultiSelection-test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/MultiSelection/MultiSelection.js b/lib/MultiSelection/MultiSelection.js index a173d03d8..0270b0464 100644 --- a/lib/MultiSelection/MultiSelection.js +++ b/lib/MultiSelection/MultiSelection.js @@ -256,7 +256,6 @@ const MultiSelection = ({ break; } }, - // stateReducer(state, actionAndChanges) { const { changes, type } = actionAndChanges switch (type) { @@ -274,7 +273,7 @@ const MultiSelection = ({ }); setFilterValue(''); return { - isOpen: false, // keep the menu open after selection. + isOpen: false, // close the menu. highlightedIndex, // don't move highlight cursor back to top of list on selection. } } else { diff --git a/lib/MultiSelection/tests/MultiSelection-test.js b/lib/MultiSelection/tests/MultiSelection-test.js index 5eb31c00a..726af92cd 100644 --- a/lib/MultiSelection/tests/MultiSelection-test.js +++ b/lib/MultiSelection/tests/MultiSelection-test.js @@ -610,6 +610,16 @@ describe('MultiSelect', () => { it('calls the action\'s onSelect function', () => converge(() => { if (!actionSelected) throw new Error('MultiSelection - action should be executed'); })); }); + + describe('clicking a filtered action', () => { + beforeEach(async () => { + await multiselection.filter('act'); + await multiselection.select('actionItem'); + }); + + it('calls the action\'s onSelect function', () => converge(() => { if (!actionSelected) throw new Error('MultiSelection - action should be executed'); })); + it('clears the filter value', () => multiselection.has({ filterValue: '' })); + }); }); describe('asyncFiltering', () => {