Semantic-Org/Semantic-UI-React
View on GitHubDropdown: Blurring the field doesn't trigger `onChange`
Open
#3648 opened on Jun 7, 2019
bughelp wantedstale
Description
Bug Report
Steps
- Create a
Dropdownfield withvalue,allowAdditions,searchprops. - Type something in the
SearchInputand press Tab to blur the field.
Expected Result
Blurring the field should trigger an onChange with the value typed in the dropdown.
Actual Result
onChange is not triggered and Dropdown keeps the old value.
Version
0.85.0 f735a58f - this commit is the first one that makes the issue appear
Testcase
https://codesandbox.io/s/semantic-ui-react-hcc64
As far as I checked the problem arises from the fact that setSelectedIndex is not being called before a call to makeSelectedItemActive.
Not sure if that is the right solution but I fixed it with
diff --git i/src/modules/Dropdown/Dropdown.js w/src/modules/Dropdown/Dropdown.js
index 7bb644d0..675ea2da 100644
--- i/src/modules/Dropdown/Dropdown.js
+++ w/src/modules/Dropdown/Dropdown.js
@@ -734,6 +734,7 @@ export default class Dropdown extends Component {
_.invoke(this.props, 'onBlur', e, this.props)
if (selectOnBlur && !multiple) {
+ this.setSelectedIndex(e.target.value)
this.makeSelectedItemActive(e)
if (closeOnBlur) this.close()
}