From c843e32508b025526dad33eec43bb9fbfd89745c Mon Sep 17 00:00:00 2001 From: Denys Bohdan Date: Wed, 1 Nov 2023 13:30:53 +0100 Subject: [PATCH] UIIN-2477 Inventory search/browse: Do not retain checkbox selections when toggling search segment. (#2326) --- CHANGELOG.md | 4 +--- src/components/InstancesList/InstancesList.js | 7 ++++++- .../InstancesList/InstancesList.test.js | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 385679a4e..9a7e26e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,9 @@ ## [11.0.0] IN PROGRESS * *BREAKING* Replace imports from quick-marc with stripes-marc-components. Refs UIIN-2636. - -## [10.1.0] IN PROGRESS - * Make Inventory search and browse query boxes expandable. Refs UIIN-2493. * Added support for `containsAny` match option in Advanced search. Refs UIIN-2486. +* Inventory search/browse: Do not retain checkbox selections when toggling search segment. Refs UIIN-2477. ## [10.0.1] IN PROGRESS diff --git a/src/components/InstancesList/InstancesList.js b/src/components/InstancesList/InstancesList.js index 2626f3d83..83dce4f6b 100644 --- a/src/components/InstancesList/InstancesList.js +++ b/src/components/InstancesList/InstancesList.js @@ -393,6 +393,11 @@ class InstancesList extends React.Component { document.getElementById('input-inventory-search').focus(); } + handleSearchSegmentChange = (segment) => { + this.refocusOnInputSearch(segment); + this.setState({ selectedRows: {} }); + } + onSearchModeSwitch = () => { const { namespace, @@ -415,7 +420,7 @@ class InstancesList extends React.Component { /> ); diff --git a/src/components/InstancesList/InstancesList.test.js b/src/components/InstancesList/InstancesList.test.js index 2680d5c2f..cb1324a32 100644 --- a/src/components/InstancesList/InstancesList.test.js +++ b/src/components/InstancesList/InstancesList.test.js @@ -221,6 +221,22 @@ describe('InstancesList', () => { }); }); + describe('when search segment is changed', () => { + it('should clear selected rows', () => { + const { + getAllByLabelText, + getByText, + } = renderInstancesList({ + segment: 'instances', + }); + + fireEvent.click(getAllByLabelText('Select instance')[0]); + fireEvent.click(getByText('Holdings')); + + expect(getAllByLabelText('Select instance')[0].checked).toBeFalsy(); + }); + }); + describe('when a user performs a search and clicks the `Next` button in the list of records', () => { describe('then clicks on the `Browse` lookup tab and then clicks `Search` lookup tab', () => { it('should avoid infinity loading by resetting the records on unmounting', () => {