Chip preventing default on keydown events
See original GitHub issueCurrently I have an Input
sitting inside the label
of a Chip
, and the way “backspace” is handled causes several issues with this text input. I’m able to stop the onDelete
function being called, but cannot fix the fact Input
is never getting an event.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
I would prefer Chip
not handle “backspace” keydown
events, but if this is desired functionality, being able to override the onKeyDown
event unconditionally would suffice.
Current Behavior
The default event is prevented and the onChange
function is never called.
Steps to Reproduce (for bugs)
I spun this up to demo the issue: https://codesandbox.io/s/42708vl2l9
Context
I’m creating a filter system for a desktop-only application, where the filters are editable and represented by Chip
s. Currently these filters are pretty simple, so editing them inline is pretty clean and simple from a user perspective.
Your Environment
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.32 |
React | 16.2.0 |
browser | Chrome |
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@maxdubrinsky I agree. I think that it’s an issue on our end. I think that the event listener https://github.com/mui-org/material-ui/blob/2de755d97f0d676f221b41446c78f9b54fa54a37/src/Chip/Chip.js#L101 should only listen to events triggered on the root element, not the child ones. We can prune the excution with the following logic:
event.currentTarget === event.target
<>this.chipRef === event.target
.@maxdubrinsky I don’t the link with mocha. Maybe you can hit us with what you have and I can have a look?