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

[Select] Consistency with Autocomplete #18136

Open
1 task done
skoging opened this issue Nov 1, 2019 · 11 comments
Open
1 task done

[Select] Consistency with Autocomplete #18136

skoging opened this issue Nov 1, 2019 · 11 comments
Labels
component: autocomplete This is the name of the generic UI component, not the React module! component: select This is the name of the generic UI component, not the React module! design: material This is about Material Design, please involve a visual or UX designer in the process

Comments

@skoging
Copy link
Contributor

skoging commented Nov 1, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

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-vh5lx

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 1, 2019

@skoging What's the incentive for using the Autocomplete instead of the Select component if you "remove" the textbox? I mean, I believe both components styles are very close, what do you miss?

Maybe #18493?

@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Nov 1, 2019
@cooperjones
Copy link

cooperjones commented Nov 2, 2019

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).
A big difference between the AutoComplete and Select components is the positioning method for the listbox. The Select component uses the Popover component which forces focus and blocks scrolling, while the AutoComplete component uses a Popper which allows scrolling and does not block focus. This leads to differences in the tabbing logic, menu positioning, etc., between the two components.
Additionally, the dropdown icon in the AutoComplete component uses an IconButton w/ separate interaction & hover/focus styles whereas the dropdown icon in the Select component uses a non-interactable svg element.

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.

@eps1lon
Copy link
Member

eps1lon commented Nov 2, 2019

@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.

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 2, 2019

@eps1lon 💯👍 .

@cooperjones Thanks, so to sum-up, we have the following difference:

  • 1. The Select positioning is different from the Autocomplete fixed in v5.

Capture d’écran 2019-11-02 à 17 02 58
vs
Capture d’écran 2019-11-02 à 17 03 22

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',
    },
  }}
>

Capture d’écran 2019-11-02 à 17 07 51
Actually, I'm even wondering if we shouldn't make it the default, per the latest specification:

Capture d’écran 2019-11-02 à 17 27 35

@oliviertassinari oliviertassinari added the new feature New feature or request label Nov 2, 2019
@skoging
Copy link
Contributor Author

skoging commented Nov 2, 2019

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 readOnly workaround being much less hacky, this isn't a particularly high priority issue for us. In my opinion the focus should be on getting the Autocomplete component stable and into core. Then perhaps take look at the future of the Select component, using the lessons and experiences gained implementing the Autocomplete.

@bmulcahy
Copy link

bmulcahy commented Nov 6, 2019

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

@oliviertassinari oliviertassinari added the priority: important This change can make a difference label Nov 16, 2019
@oliviertassinari oliviertassinari removed the priority: important This change can make a difference label Dec 1, 2019
@oliviertassinari oliviertassinari changed the title [Autocomplete] A way to disable just the text input [Autocomplete] Match styles of the Select Feb 22, 2020
@oliviertassinari oliviertassinari changed the title [Autocomplete] Match styles of the Select [Autocomplete] Consistency with Select Feb 22, 2020
@oliviertassinari oliviertassinari added component: select This is the name of the generic UI component, not the React module! design: material This is about Material Design, please involve a visual or UX designer in the process component: autocomplete This is the name of the generic UI component, not the React module! and removed new feature New feature or request component: autocomplete This is the name of the generic UI component, not the React module! labels Feb 22, 2020
@oliviertassinari oliviertassinari changed the title [Autocomplete] Consistency with Select [Select] Consistency with Autocomplete Feb 22, 2020
@oliviertassinari oliviertassinari removed the component: autocomplete This is the name of the generic UI component, not the React module! label Sep 19, 2020
@oliviertassinari oliviertassinari added this to the v5 milestone Oct 10, 2020
@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Oct 28, 2020
@Nziranziza
Copy link

Nziranziza commented Nov 23, 2020

I have added these but It doesn't seem to work for me

<Select
  MenuProps={{
    getContentAnchorEl: null,
    anchorOrigin: {
      vertical: 'bottom',
      horizontal: 'center',
    },
    transformOrigin: {
      vertical: 'top',
      horizontal: 'center',
    },
  }}
>

1
2

@oliviertassinari
Copy link
Member

@Nziranziza It's expected, there isn't enough space to display the whole list below the select.

@oliviertassinari oliviertassinari modified the milestones: v5-beta, v5.1 May 9, 2021
@oliviertassinari
Copy link
Member

So far, we are waiting for the reimplementation of the Select (e.g. to use Popper over Popover) before closing this issue.

@danielpza
Copy link

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?

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 29, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! component: select This is the name of the generic UI component, not the React module! design: material This is about Material Design, please involve a visual or UX designer in the process
Projects
None yet
Development

No branches or pull requests

7 participants