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

(feat) Display all items on ui-select-extended #440

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,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 @@ -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 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
Loading