DigitalRiver / react-atlas

Composable React components with CSS Modules.
http://digitalriver.github.io/react-atlas/
MIT License
38 stars 25 forks source link

Dropdown: tempIndex is not reset when user enters text into filter #836

Closed Darper closed 6 years ago

Darper commented 6 years ago

Steps to reproduce:

  1. Go to State Dropdown example in docs site
  2. Expand Dropdown
  3. Hover over an option after the first item in the list
  4. Type "Minnesota"
  5. Hit Enter

Expected result: Dropdown closes as "Minnesota" option was already selected. Actual result: Stack trace ...

  496 | },
  497 | () => {
  498 |   if (!this.state.active && this.state.tempIndex !== null) {
> 499 |     const newValue = this.state.options[this.state.tempIndex].props
      |                                                              ^  500 |       .value;
  501 |     this.optionOnClick(null, newValue, this.state.tempIndex);
  502 |   }

Suggested fix: Reset tempIndex to null in _handleChange setState call.

floydchenchen commented 6 years ago

this issue is fixed by the latest commit in issue #762 since two issues are closely related.