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.

onChange not called when selectedItem is already set to the inputs value

See original GitHub issue
  • downshift version: 1.13
  • node version: codesandbox
  • npm (or yarn) version: codesandbox

Problem description:

Go to the typeahead example

  • Type “orange”
  • Wait for the selection list to appear.
  • Select “orange”

The alert “You selected orange” does not appear, because onChange is not triggered. Probably caused by: https://github.com/paypal/downshift/blob/master/src/downshift.js#L283

Suggested solution: Would anything speak against calling onChange even if the value did not change, as long as selectedItem is part of stateToSet? Or maybe allow by flag?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, Oct 23, 2017

Yep, after considering it, I’ll merge any PR that implements this in a way that’s as simple as possible, is tested, and documented 👍

1reaction
kentcdoddscommented, Oct 23, 2017

Hmmm… So I’m thinking that maybe adding an onSelect may not be a terribly bad idea. This behavior (the current behavior) makes sense to me:

type apple -> select apple -> onChange and onSelect called press arrow down -> select apple -> onChange not called, onSelect called

I think that’s what you suggested in the first place. Is that right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why am I not getting the value from onChange with Select?
To obtain the value of the selected option, you need to get the selected option from the options by selectedIndex and then get...
Read more >
useCombobox - Downshift
It returns a set of props that are meant to be called and their results destructured on the ... selectedItem, State value with...
Read more >
react input onchange doesn't work - You.com | The AI Search ...
When attaching Inputmask to event inside of react component there is no way to know when value has been changed. React uses input...
Read more >
SCR19: Using an onchange event on a select element ... - W3C
Navigate to the trigger select element, navigate through the options but do not change the value. Check that the matching option values are...
Read more >
Select - Ant Design
virtual, Disable virtual scroll when set to false, boolean ; onBlur, Called when blur, function ; onChange, Called when select an option or...
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