Skip to content

Commit

Permalink
(feat) O3-3911 Display all items on ui-select-extended (#440)
Browse files Browse the repository at this point in the history
* (feat) Display all items on ui-select-extended

* update branch

* remove filtering prop to use carbon's default filtering
  • Loading branch information
ODORA0 authored Jan 6, 2025
1 parent 3e4e2fa commit 266dfe4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ const UiSelectExtended: React.FC<FormFieldInputProps> = ({ 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());
}}
onChange={({ selectedItem }) => {
isProcessingSelection.current = true;
setFieldValue(selectedItem?.uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,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 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();
});
});

Expand Down

0 comments on commit 266dfe4

Please sign in to comment.