Select event.value !== event.target.value
See original GitHub issueWhen I change the option in a Select, event.value
is the one I selected, and event.target.value
is the previously selected option. This is obviously not the correct behavior.
This is a pretty simple issue so unless this is unknown behavior / hard to repro, I’ll leave it at that.
Your Environment
- Grommet version: 2.7.1
- Browser Name and version: Chrome 74.0.3729.169
- Operating System and version (desktop or mobile): Desktop
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Why select option change event can't have ... - Stack Overflow
In select option change event,why can't we get this or event.target to get selected value instead of writing clumsy code like $( "select...
Read more >HTMLInputElement: select event - Web APIs - MDN Web Docs
The select event fires when some text has been selected. ... const selection = event.target.value.substring(event.target.
Read more >`e.target.value` reflects <select value={}> not <option ... - GitHub
Whenever the onChange is triggered, the e.target.value is 1. I'm assuming this is because that is the value starts with.
Read more >target Event Property - W3Schools
The target event property returns the element that triggered the event. ... Return Value: A reference to the object on which the event...
Read more >Get the Value/Text of Select or Dropdown on Change using JS
addEventListener('change', function handleChange(event) { console.log(event.target.value); // 👉️ get ...
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 FreeTop 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
Top GitHub Comments
I just verified this. It is fixed in
v2.17.2
with 518373864c2608df9faf4a6de8900ef5a55d8f20 Note thatevent.target.value === event.value
will be true for single selection only.If
multiple
prop is set these 2 values will not be equal. In that caseevent.target.value
will hold previous value, andevent.value
will be an array. In my opinionevent.target.value
should be avoided whenmultiple
prop is true.@ShimiSun I guess this can be closed now
Closing since #5155 was merged