-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[RFC] Better consistency between Autocomplete and Select #43979
Comments
Autocomplete, whilst convenient sometimes, does not work properly with hydration (it flickers, maybe the internal state management is relying on useEffect, which would explain it, but I haven't checked). See for example with query strings. If you refresh the page, Select and TextField (select mode) hydrate immediately, whereas Autocomplete shows the empty state then hydrates with the value. https://codesandbox.io/p/devbox/5swdg3 That is to say that any solution that makes Select/TextField similarly badly behaved during hydration should be avoided, IMO. That said, if Autocomplete hydrated properly on initial render then I'd use it almost every time. |
@joshkel Thanks for opening this issue ~ I think the inconsistencies you bring up would first be addressed by: |
Can we also add to the list It looks like this change was made in joy-ui, but wasn't made in MUI. Not seeing it in either linked issues either. |
@blarson-hearst In Material UI, which combination of variant/size of these are mismatched now? If it's obviously wrong maybe we can fix it as a bug |
These don't really depend on Base UI, maybe they can be considered in v8? @aarongarciah |
@mj12albert Select and Autocomplete both have only 2 sizes, neither of which seems to match any of the sizes for TextField or Button sizing. |
What's the problem?
I'm exploring replacing some of our Select components with Autocomplete components (using the default combo box mode). My assumption was that these would look and act more or less the same as Select components, with the added ability to filter the list by typing on the keyboard. However, the components have several differences in appearance and behavior:
elevation
of 8, while Autocomplete gives itsPaper
an elevation of 2).What are the requirements?
Greater consistency and compatibility - avoid noticeable UX differences, unless there are clear reasons for them
What are our options?
Issues 1-3 (differences in modal, focus handling, and positioning) are likely the result of Select's use of Menu and Popover versus Autocomplete's use of Popper. This may be related to #38756.
Items 4-5 and (to some extent) 6 can be handled by changes to props and components, although I personally would appreciate not needing to apply these customizations myself.
Item 8 seems like a desirable difference: the autocomplete element needs to stay visible so the user can see what they're typing, and limiting the height seems perfectly reasonable.
(There may be UX issues I haven't considered that argue against changing any or all of these.)
Proposed solution
Some simple starting changes would include changing Autocomplete's Paper's elevation to 8 to match Popover and changing it to pass
minWidth
instead ofwidth
to the Popper's style.Resources and benchmarks
https://stackblitz.com/edit/react-3apdzs?file=Demo.tsx has a side-by-side comparison of Select and Autocomplete, including a demonstration of some props and component changes to make Autocomplete more like Select.
Customizing Autocomplete width has come up before: #19376
Search keywords:
The text was updated successfully, but these errors were encountered: