question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select event.value !== event.target.value

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bojan88commented, May 7, 2021

I just verified this. It is fixed in v2.17.2 with 518373864c2608df9faf4a6de8900ef5a55d8f20 Note that event.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 case event.target.value will hold previous value, and event.value will be an array. In my opinion event.target.value should be avoided when multiple prop is true.

@ShimiSun I guess this can be closed now

0reactions
jcfilbencommented, Jun 30, 2021

Closing since #5155 was merged

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found