This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Issue: `react-select` `onChange` method doesn't return a proper event | |
// | |
// Solution used: | |
// | |
// The main idea is to have an hidden `select` that will trigger a real event | |
// When `ReactSelect` triggers it's `onChange` we set the state with the `selectedOptions` | |
// these `selectedOptions` will be what populate our hidden select. | |
// Using the callback from `setState` (it ensures that the new values are already into our hidden select), | |
// we then create a change event and dispatch it into our hidden select. | |
// This will cause the `onChange` from this select to be triggered with a proper `event`. |