From 1b6dca3c391206481dde5d02f680dc27cc0d5191 Mon Sep 17 00:00:00 2001 From: Dmytro-Melnyshyn <77053927+Dmytro-Melnyshyn@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:50:34 +0300 Subject: [PATCH] UIIN-2533: Show facet options, if they exist, after clicking the +More button. (#2309) --- CHANGELOG.md | 1 + .../CheckboxFacet/CheckboxFacetList.js | 36 ++++++++++--------- .../CheckboxFacet/CheckboxFacetList.test.js | 21 +++++++++++ .../InstanceFilters/InstanceFilters.js | 3 ++ src/facetUtils.js | 5 +++ src/facetUtils.test.js | 1 + 6 files changed, 50 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d1177cb1..1bf6cba1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Consortial holdings accordion is not appearing after the sharing of Instance. Fixes UIIN-2629. * Reset CheckboxFacet state.more when user resets search form and fewer facet options are loaded. Fixes UIIN-2531. * Edit instance success toast no longer shows the instance HRID. Fixes UIIN-2588. +* Show facet options, if they exist, after clicking the +More button. Refs UIIN-2533. ## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13) [Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0) diff --git a/src/components/CheckboxFacet/CheckboxFacetList.js b/src/components/CheckboxFacet/CheckboxFacetList.js index 0212566e4..d1b76bb59 100644 --- a/src/components/CheckboxFacet/CheckboxFacetList.js +++ b/src/components/CheckboxFacet/CheckboxFacetList.js @@ -52,23 +52,25 @@ function CheckboxFacetList({ } - {!isPending && dataOptions.map(({ count, value, label, disabled, readOnly }) => { - const name = typeof label === 'string' ? label : value; - return ( - - ); - })} + {!isPending && dataOptions + .filter(({ isDeleted }) => !isDeleted) + .map(({ count, value, label, disabled, readOnly }) => { + const name = typeof label === 'string' ? label : value; + return ( + + ); + })} {!isPending && showMore && ( diff --git a/src/components/CheckboxFacet/CheckboxFacetList.test.js b/src/components/CheckboxFacet/CheckboxFacetList.test.js index 917dbf1fb..a436fdd0c 100644 --- a/src/components/CheckboxFacet/CheckboxFacetList.test.js +++ b/src/components/CheckboxFacet/CheckboxFacetList.test.js @@ -38,6 +38,7 @@ const dataOptions = [ label: 'Check Box 2', value: 'checkBox2', }, + { id: 'fakeId', isDeleted: true }, ]; const selectedValues = ['checkBox1']; const fieldName = 'testFacet'; @@ -123,4 +124,24 @@ describe('CheckboxFacetList', () => { const checkBoxs = screen.findAllByRole('checkbox'); expect(checkBoxs).toMatchObject({}); }); + + it('should not render deleted options', () => { + render( + , + ); + + const allOptions = screen.getAllByRole('checkbox').length; + + expect(allOptions).toBe(2); + }); }); diff --git a/src/components/InstanceFilters/InstanceFilters.js b/src/components/InstanceFilters/InstanceFilters.js index c74fec2ee..250f50707 100644 --- a/src/components/InstanceFilters/InstanceFilters.js +++ b/src/components/InstanceFilters/InstanceFilters.js @@ -444,6 +444,9 @@ const InstanceFilters = props => { selectedValues={activeFilters[FACETS.STATUS]} isPending={getIsPending(FACETS.STATUS)} onChange={onChange} + isFilterable + onSearch={handleFilterSearch} + onFetch={handleFetchFacets} /> { const key = 'id'; const expectedOptions = [ { label: 'Filter 1', value: 'filter1', count: 2 }, + { id: 'invalid', isDeleted: true }, { label: 'Filter 2', value: 'filter2', count: 0 }, ]; expect(getFacetOptions(selectedFiltersId, entries, facetData, key)).toEqual(expectedOptions);