Fix select switching to multiple in IE

This one was an actual behavioral bug rather than a bug with the tests; our intention was that the first element from the `defaultValue` array would remain selected but IE seemed to be choosing the last one instead. Now we set the value for uncontrolled components in componentDidUpdate when switching from multiple to non-multiple to ensure that a consistent option gets selected.

Test Plan: Ran the ReactDOMSelect tests in jest, phantomjs, IE10, Chrome, and Firefox. Also tested an uncontrolled select manually to make sure that nothing crazy happened when switching between options.
This commit is contained in:
Ben Alpert 2014-06-07 19:13:11 -07:00
parent eebcf9f888
commit eaa68b8e6b
1 changed files with 4 additions and 2 deletions

View File

@ -141,9 +141,11 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
updateOptions(this, LinkedValueUtils.getValue(this));
},
componentDidUpdate: function() {
componentDidUpdate: function(prevProps) {
var value = LinkedValueUtils.getValue(this);
if (value != null) {
var prevMultiple = !!prevProps.multiple;
var multiple = !!this.props.multiple;
if (value != null || prevMultiple !== multiple) {
updateOptions(this, value);
}
},