Skip to content

Commit

Permalink
STCOM-1385 Clear filter value after an action is chosen from MultiSel…
Browse files Browse the repository at this point in the history
…ection (#2393)

* clear filter value after an action is chosen from MultiSelection's option list.

* add tests for removed filter value, updated comment
  • Loading branch information
JohnC-80 authored Nov 21, 2024
1 parent 46ce739 commit a3e41cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Wrap `<Selection>` in full-width div. Refs STCOM-1332.
* Assign `<Modal>`'s exit key handler to Modal's element rather than `document`. refs STCOM-1382.
* Wrap `<Card>`'s render output in `<StripesOverlayContext>` 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)
Expand Down
4 changes: 2 additions & 2 deletions lib/MultiSelection/MultiSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ const MultiSelection = ({
break;
}
},
//
stateReducer(state, actionAndChanges) {
const { changes, type } = actionAndChanges
switch (type) {
Expand All @@ -272,8 +271,9 @@ const MultiSelection = ({
selectedItems,
reset
});
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 {
Expand Down
10 changes: 10 additions & 0 deletions lib/MultiSelection/tests/MultiSelection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit a3e41cd

Please sign in to comment.