Dropdown: when options contain custom elements, setState in onChange leads to mismatch of 'active' and 'selected' option
#2296 opened on Nov 6, 2017
Description
Steps
I want to setState() within onChange of the Dropdown and have custom elements within the options like so:
const options = [ { value: "1",
content: <span>a</span>
}, ... ];
Expected Result
-
The selected option should be active and selected
-
The state should be set and the dropdown should change its value. The content of the option
<span>a</span>should appear in the dropdown.
Actual Result
-
The state is set as expected. The selected option is set to active, the previously selected option is kept as selected. => Selected and active do not match the same option anymore
-
The content does not appear in the dropdown
If text is used instead of content
-
The selected option is set to active, the previously selected option is kept as selected. => Selected and active do not match the same option anymore
-
The content does appear in the dropdown
Questions:
What should I use, text or content for this case?
How to solve the mismatch?
Version
0.76.0
Showcase https://codesandbox.io/s/pp0w7wrn7q
Partially solved here: https://github.com/Semantic-Org/Semantic-UI-React/pull/2252