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: Changes the Select component to preserve the search value when selecting #23869

Merged
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 @@ -396,6 +396,7 @@ describe('Horizontal FilterBar', () => {
setFilterBarOrientation('horizontal');
enterNativeFilterEditModal();
inputNativeFilterDefaultValue('Albania');
cy.get('.ant-select-selection-search-input').clear({ force: true });
inputNativeFilterDefaultValue('Algeria', true);
saveNativeFilterSettings([SAMPLE_CHART]);
cy.getBySel('filter-bar').within(() => {
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/components/Select/AsyncSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ const AsyncSelect = forwardRef(
<StyledSelect
allowClear={!isLoading && allowClear}
aria-label={ariaLabel || name}
autoClearSearchValue={false}
dropdownRender={dropdownRender}
filterOption={handleFilterOption}
filterSort={sortComparatorWithSearch}
Expand Down
7 changes: 7 additions & 0 deletions superset-frontend/src/components/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ const type = (text: string) => {
return userEvent.type(select, text, { delay: 10 });
};

const clearTypedText = () => {
const select = getSelect();
userEvent.clear(select);
};

const open = () => waitFor(() => userEvent.click(getSelect()));

test('displays a header', async () => {
Expand Down Expand Up @@ -801,6 +806,7 @@ test('"Select All" is checked when unchecking a newly added option and all the o
expect(await findSelectOption(selectAllOptionLabel(10))).toBeInTheDocument();
// add a new option
await type(`${NEW_OPTION}{enter}`);
clearTypedText();
expect(await findSelectOption(selectAllOptionLabel(11))).toBeInTheDocument();
expect(await findSelectOption(NEW_OPTION)).toBeInTheDocument();
// select all should be selected
Expand Down Expand Up @@ -830,6 +836,7 @@ test('does not render "Select All" when there are 0 or 1 options', async () => {
);
expect(screen.queryByText(selectAllOptionLabel(1))).not.toBeInTheDocument();
await type(`${NEW_OPTION}{enter}`);
clearTypedText();
expect(screen.queryByText(selectAllOptionLabel(2))).toBeInTheDocument();
});

Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ const Select = forwardRef(
<StyledSelect
allowClear={!isLoading && allowClear}
aria-label={ariaLabel || name}
autoClearSearchValue={false}
dropdownRender={dropdownRender}
filterOption={handleFilterOption}
filterSort={sortComparatorWithSearch}
Expand Down