-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Unable to trigger click events on Chips #18658
Comments
@jonsmithers This is something we have seen coming and I didn't think it was worth supporting out of the box. I'm aware of these workarounds:
Would that work for you? |
We actually weren't aware Setting the From what I can tell, Chip's <Chip deleteIcon={<Icon onMouseDown={this.onDelete} />} /> (We'd still have to have a "controlled open" with a delay to prevent the dropdown from opening.) I think we have a way forward. Thank you! |
From a developer perspective this is quite ugly. I hope there will be a way to use Chip onDelete rather than a monster like
Controlling the open state "with a delay" is definitely not an option. Customizing Autocomplete to remove the text input field introduces other problems. |
I think that we should keep the chips as presentational only for this component. Head to the Autocomplete for something more dynamic: https://material-ui.com/components/autocomplete/. |
in case someone is still struggling... by stopping the event propagation, the <Chip
...
onMouseDown={e => {
e.stopPropagation()
}
onDelete={() => {
// do whatever
}}
/> IMO this behaviour is very unexpected and leads to bad UX |
Wasn't able to get this to work but seeing you put {chips.map((c) => {
<li>
<Chip
...
onDelete={() => {
handleDeleteChip(c)
}}
/>
</li>
} |
Hi ppl, Just posting the fix for my scenario.
Note: I'm using MUI 4.x version |
WTF this worked for me too |
This works for me. Very Thanks |
Current Behavior 😯
There is no obvious way to listen for click events on Chip components inside a Select component.
Expected Behavior 🤔
Should be able to listen for click events, which was possible in version 4.7.0.
Steps to Reproduce 🕹
https://codesandbox.io/s/fervent-murdock-mcc7i?fontsize=14&hidenavigation=1&theme=dark
NOTE - When you change the version from 4.7.1 to 4.7.0 in package.json, this issue goes away. It appears this issue was introduced very recently.
Context 🔦
We want to add the "x" delete button to Chips so the user can remove them without re-opening the dropdown.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: