Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCOM-1385 Clear filter value after an action is chosen from MultiSelection #2393

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading