From e197711fc3db862c5e3bb684cd8fdf90f2360410 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Thu, 21 Nov 2024 10:40:28 -0600 Subject: [PATCH] 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', () => {