From 3ac51b61f9cda2101d50d35c44dfc5d616e6cfd1 Mon Sep 17 00:00:00 2001 From: AJAL ODORA JONATHAN <43242517+ODORA0@users.noreply.github.com> Date: Wed, 4 Dec 2024 22:05:01 +0300 Subject: [PATCH 1/3] (feat) Display all items on ui-select-extended --- .../ui-select-extended.component.tsx | 8 +------- .../ui-select-extended.test.tsx | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx index bd8df9e6..87feeff9 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx @@ -148,13 +148,7 @@ const UiSelectExtended: React.FC = ({ field, errors, warnin itemToString={(item) => item?.display} selectedItem={selectedItem} placeholder={isSearchable ? t('search', 'Search') + '...' : null} - shouldFilterItem={({ item, inputValue }) => { - if (!inputValue) { - // Carbon's initial call at component mount - return true; - } - return item.display?.toLowerCase().includes(inputValue.toLowerCase()); - }} + shouldFilterItem={() => true} onChange={({ selectedItem }) => { isProcessingSelection.current = true; setFieldValue(selectedItem?.uuid); diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx index acc13404..e7167d60 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx @@ -253,18 +253,27 @@ describe('UiSelectExtended', () => { ); }); - it('should filter items based on user input', async () => { + it('should display all items regardless of user input', async () => { await act(async () => { renderForm(); }); - const transferLocationSelect = await findSelectInput(screen, 'Transfer Location'); + const transferLocationSelect = await findSelectInput(screen, 'Transfer Location'); + // Open the dropdown await user.click(transferLocationSelect); + + // Verify all items are displayed initially + expect(screen.getByText('Kololo')).toBeInTheDocument(); + expect(screen.getByText('Naguru')).toBeInTheDocument(); + expect(screen.getByText('Muyenga')).toBeInTheDocument(); + + // Type some input await user.type(transferLocationSelect, 'Nag'); - + + // Verify all items are still displayed + expect(screen.getByText('Kololo')).toBeInTheDocument(); expect(screen.getByText('Naguru')).toBeInTheDocument(); - expect(screen.queryByText('Kololo')).not.toBeInTheDocument(); - expect(screen.queryByText('Muyenga')).not.toBeInTheDocument(); + expect(screen.getByText('Muyenga')).toBeInTheDocument(); }); }); From 915109b535266312722cbf4a827a157d65ad5616 Mon Sep 17 00:00:00 2001 From: AJAL ODORA JONATHAN <43242517+ODORA0@users.noreply.github.com> Date: Thu, 5 Dec 2024 07:41:59 +0300 Subject: [PATCH 2/3] update branch --- .../inputs/ui-select-extended/ui-select-extended.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx index e7167d60..54732819 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx @@ -267,7 +267,7 @@ describe('UiSelectExtended', () => { expect(screen.getByText('Naguru')).toBeInTheDocument(); expect(screen.getByText('Muyenga')).toBeInTheDocument(); - // Type some input + // Type input await user.type(transferLocationSelect, 'Nag'); // Verify all items are still displayed From 3d5b2653b5d9db4e710752b076703d3281901519 Mon Sep 17 00:00:00 2001 From: AJAL ODORA JONATHAN <43242517+ODORA0@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:01:34 +0300 Subject: [PATCH 3/3] remove filtering prop to use carbon's default filtering --- .../inputs/ui-select-extended/ui-select-extended.component.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx index 87feeff9..7e9d028d 100644 --- a/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +++ b/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx @@ -148,7 +148,6 @@ const UiSelectExtended: React.FC = ({ field, errors, warnin itemToString={(item) => item?.display} selectedItem={selectedItem} placeholder={isSearchable ? t('search', 'Search') + '...' : null} - shouldFilterItem={() => true} onChange={({ selectedItem }) => { isProcessingSelection.current = true; setFieldValue(selectedItem?.uuid);