Onchange event for <select> is not propagated in react when not used with class "browser-default"
See original GitHub issueI use materialize with react and had an issue on <select>
s onChange event propagation.
This way the event is not fired, this.handleSelectChange
is not called.
<select value="B" onChange={this.handleSelectChange}>
<option value="A">Apple</option>
<option value="B">Banana</option>
<option value="C">Cranberry</option>
</select>
When i add the class browser-default
to select
it works pretty well.
<select className="browser-default" value="B" onChange={this.handleSelectChange}>
<option value="A">Apple</option>
<option value="B">Banana</option>
<option value="C">Cranberry</option>
</select>
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Onchange event for <select> is not propagated in materialize ...
I use materialize css framework with react and had an issue on <select> s onChange event propagation. This way the event is not...
Read more >Developers - Onchange event for <select> is not propagated in ...
I use materialize css framework with react and had an issue on <select> s onChange event propagation. This way the event is not...
Read more >OnChange event using React JS for drop down - Stack Overflow
The change event is triggered on the <select> element, not the <option> element. However, that's not the only problem.
Read more >Handling Events :: Eloquent JavaScript
You can use this property to ensure that you're not accidentally handling something that propagated up from a node you do not want...
Read more >SyntheticEvent - React
The synthetic events are different from, and do not map directly to, the browser's ... false from an event handler will no longer...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Based on comments in the other thread, I worked around this with the code below:
This is probably caused by the fact that selects often ignore user input, as described in this bug report I filed: https://github.com/Dogfalo/materialize/issues/4098
Please re-open that issue, and mark this as a duplicate. I described and fixed an input event tracking problem that causes select menus to ignore the item you select, if you don’t click on it very quickly, or if you press down and drag.
To demonstrate this, try popping up the menu by clicking (because pressing and dragging does not work, and starts a text selection gesture, which is another bug), then point at an item different than the currently selected item, then click very quickly. If you click quickly enough, it works. Then try clicking on another item than the one you just selected, but more slowly so you’re holding the button or finger down for about half a second to a second. (Not a press-and-hold gesture, which is slower, but just a slow click, which is very common for people to do.) Notice that the menu pops down at the instant you press down on the button or touch the screen, but the onclick handler that reports the selected item is never called. That is the bug I reported and fixed, but it was closed unfortunately because the developers don’t see it as a bug. But it certainly is.