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

[material-ui][Autocomplete] Display options provided to the options prop even if loading is true. #41677

Merged
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
2 changes: 1 addition & 1 deletion packages/mui-material/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(inProps, ref) {
);

let autocompletePopper = null;
if (!loading && groupedOptions.length > 0) {
if (groupedOptions.length > 0) {
autocompletePopper = renderAutocompletePopperChildren(
<AutocompleteListbox
as={ListboxComponent}
Expand Down
17 changes: 17 additions & 0 deletions packages/mui-material/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ describe('<Autocomplete />', () => {
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
expect(document.querySelector(`.${classes.paper}`).textContent).to.equal('Loading…');
});

it('should show supplied options to the "options" prop even when loading', () => {
render(
<Autocomplete
options={['one', 'two']}
loading
renderInput={(params) => <TextField {...params} autoFocus />}
/>,
);

fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
expect(document.querySelector(`.${classes.paper}`).textContent).not.to.equal('Loading…');

const listbox = screen.getByRole('listbox');
const htmlOptions = listbox.querySelectorAll('li');
expect(htmlOptions[0].innerHTML).to.equal('one');
});
});

describe('prop: autoHighlight', () => {
Expand Down
Loading