Dropdown: Selecting item with Enter in search Dropdown prevents focusing other refs
#3504 opened on Mar 14, 2019
Description
Bug Report
Steps
- Create a
Dropdownwithsearchenabled andselectOnNavigation={false} - Create an input with a
ref - In the Dropdown's
onChangehandler, focus the input ref
This issue is only triggered when selecting an item using the Enter key. It does not occur when clicking the item, when selecting an item via onBlur, and it doesn't occur when not using a search dropdown.
I believe it is tied to this line: https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Dropdown/Dropdown.js#L585
Here is a code sandbox replicating the issue: https://codesandbox.io/s/k5p18q3l27
(Note: Selecting an item with Enter will cause a loop and freeze that browser tab, you'll need to end the process manually from the task manager)
Expected Result
The dropdown selects the item, closes, and the next input is automatically focused.

Actual Result
When selecting an item with Enter it causes an endless loop of
Dropdown.onChange
inputRef.current.focus()
Dropdown.onBlur
Dropdown.onChange
Dropdown.onClose
inputRef.current.focus()
Dropdown.onBlur
Dropdown.onChange
Dropdown.onClose
inputRef.current.focus()
// repeat forever
Selecting an item with Enter should behave the same as other selection methods, and should not try to re-focus the search input after it has been closed.
Version
0.84.0