-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Select] Consistency with Autocomplete #18136
Comments
I am also implementing both searchable and non-searchable selects and am running into a similar issue making them consistent (I'm attempting to use the Select component for non-searchable selects). Not sure if this is a workable solution (I haven't had a chance to explore the a11y ramifications or test on less common platforms/browsers), but adding a readOnly attribute to the input element of the AutoComplete component seems to be a pretty good work-around to get a non-searchable combobox. The readOnly attribute maintains the listeners on the text input element (onFocus, onClick, onBlur, etc.) while also preventing any text from being entered. |
@cooperjones I think we'll revisit the Select with regards to Popper vs Popover. The current solution has a mobile first approach where the Popover makes more sense. But for a select input on desktop a Popper makes more sense. Need to do some research though first and see how this is used. |
@eps1lon 💯👍 . @cooperjones Thanks, so to sum-up, we have the following difference:
This can be configured with the Popover placement props to be identical: <Select
MenuProps={{
getContentAnchorEl: null,
anchorOrigin: {
vertical: 'bottom',
horizontal: 'center',
},
transformOrigin: {
vertical: 'top',
horizontal: 'center',
},
}}
>
|
Thanks for the response to this issue. It's good to see that it has generated a discussion around the differences and inconsistencies between Select and Autocomplete, both when it comes to styling and performance. I think @cooperjones highlighted the main incentives for using Autocomplete as a Select, and in addition the performance differences mentioned can be very noticable. With the |
So this disables the text input but how do I disable the clear and drop down? So I was able to do it by setting freeSolo={true} disableClearable={true} and doing the readOnly work around from above |
@Nziranziza It's expected, there isn't enough space to display the whole list below the select. |
So far, we are waiting for the reimplementation of the Select (e.g. to use Popper over Popover) before closing this issue. |
@oliviertassinari is there an issue or PR to keep track of the progress? |
No, consider, this issue and all the other open issues as part of the same underlying problem. The Select likely deserves to be rewritten from scratch at this point. |
Summary 💡
Equivalent to react-select's
isSearchable={false}
.Disables the search functionality, but is still consistently styled.
Examples 🌈
Motivation 🔦
Having consistent styling of searchable and non-searchable selects is a requirement we're currently facing.
This workaround works: https://codesandbox.io/s/material-demo-ok1kg, but it's not exactly pretty.
EDIT:
Updated workaround with
readOnly
prop on input suggested by @cooperjones: https://codesandbox.io/s/material-demo-vh5lxThe text was updated successfully, but these errors were encountered: