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 doesn't lose focus if element is deleted from inside its input. #18465

Closed
2 tasks done
maximovicd opened this issue Nov 20, 2019 · 8 comments
Closed
2 tasks done
Labels
component: select This is the name of the generic UI component, not the React module! out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future)

Comments

@maximovicd
Copy link

maximovicd commented Nov 20, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • The issue is present in the latest release.

Current Behavior 😯

If there is a Chip with a delete button displayed in the Input of Select component. When the delete button is clicked, the Select remains focused.

Expected Behavior 🤔

Select should lose focus or lose it after clicking outside of it again.

Steps to Reproduce 🕹

https://codesandbox.io/s/gracious-morning-ow6nn - edited

Steps:

  1. Click (in this case) the "Two" Chip's X button
  2. The Select will remain focused without possibility to click away from it to blur it.
  3. This can be viewed by clicking inside an input next to the Select.

Context 🔦

Think this is a fairly common use case.

Your Environment 🌎

Tech Version
Material-UI v4.6.1
React 16.8.6
Browser Chrome
@oliviertassinari
Copy link
Member

Why should it behave this way?

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 20, 2019

Having a closer look, I don't think that the element should lose focus by default. You can blur the element if it better suite your use case.

@oliviertassinari oliviertassinari added component: select This is the name of the generic UI component, not the React module! out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future) labels Nov 20, 2019
@maximovicd
Copy link
Author

@oliviertassinari Thanks for your quick answer. I am sorry, but you are able to make the Select lose focus at all? For me it stays focused - if there is a second input, it will get focused but Select remains colored as if focus is within it. I have edited the sandbox and steps to repro.

@oliviertassinari
Copy link
Member

@maximovicd Thanks for the updated codesandbox. It's better, we can clearly see the problem. I fear we can't do anything about it. You can work around the issue by focusing the select input back when you delete a tag. But in any case, it's not supported. You might prefer the autocomplete component for this use case.

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 21, 2019

Actually, deletable chips are likely to be "impossible" to make work once we move #17978 forward.

@maximovicd
Copy link
Author

Thanks a lot, refocusing after delete works good as a workaround!

@oliviertassinari
Copy link
Member

@maximovicd I would advise finding another way, it's not supported. Your workaround won't be working in the next release after #17978, you will have to further customize the integration (control the open prop and delay the interaction).

@emlai
Copy link
Contributor

emlai commented Sep 23, 2022

This is still an issue in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! out of scope The problem looks valid but we won't fix it (maybe we will revisit it in the future)
Projects
None yet
Development

No branches or pull requests

3 participants