Fix ReactDOMFiberSelect to set the initial values (#8349)
I forgot that the normal properties route doesn't do this. We also have to make sure that the order is 1) insert children (options), 2) set multiple 3) update the options.
Sebastian Markbåge committed
Nov 18, 2016 at 18:52 UTC
0deb71223d08f56cc6a5910288d80d8fafce3859
3 files changed
+20
-17
scripts/fiber/tests-failing.txt
-17
@@ -88,23 +88,6 @@ src/renderers/dom/shared/eventPlugins/__tests__/SimpleEventPlugin-test.js
88
src/renderers/dom/shared/wrappers/__tests__/ReactDOMInput-test.js
89
* should control a value in reentrant events
90
91
-src/renderers/dom/shared/wrappers/__tests__/ReactDOMOption-test.js
92
-* should allow ignoring `value` on option
93
-
94
-src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
95
-* should allow setting `defaultValue`
96
-* should not control when using `defaultValue`
97
-* should allow setting `defaultValue` with multiple
98
-* should allow setting `value`
99
-* should allow setting `value` with multiple
100
-* should not select other options automatically
101
-* should allow setting `value` with `objectToString`
102
-* should allow switching to multiple
103
-* should allow switching from multiple
104
-* should remember value when switching to uncontrolled
105
-* should not control defaultValue if readding options
106
-* should select grandchild options nested inside an optgroup
107
-
91
src/renderers/dom/stack/client/__tests__/ReactDOM-test.js
92
* throws in render() if the mount callback is not a function
93
* throws in render() if the update callback is not a function
scripts/fiber/tests-passing.txt
+13
@@ -831,18 +831,31 @@ src/renderers/dom/shared/wrappers/__tests__/ReactDOMOption-test.js
831
* should ignore null/undefined/false children without warning
832
* should be able to use dangerouslySetInnerHTML on option
833
* should set attribute for empty value
834
+* should allow ignoring `value` on option
835
836
src/renderers/dom/shared/wrappers/__tests__/ReactDOMSelect-test.js
837
+* should allow setting `defaultValue`
838
* should not throw with `defaultValue` and without children
839
+* should not control when using `defaultValue`
840
+* should allow setting `defaultValue` with multiple
841
+* should allow setting `value`
842
* should not throw with `value` and without children
843
+* should allow setting `value` with multiple
844
+* should not select other options automatically
845
* should reset child options selected when they are changed and `value` is set
846
+* should allow setting `value` with `objectToString`
847
+* should allow switching to multiple
848
+* should allow switching from multiple
849
+* should remember value when switching to uncontrolled
850
* should remember updated value when switching to uncontrolled
851
* should support server-side rendering
852
* should support server-side rendering with defaultValue
853
* should support server-side rendering with multiple
854
+* should not control defaultValue if readding options
855
* should refresh state on change
856
* should warn if value and defaultValue props are specified
857
* should be able to safely remove select onChange
858
+* should select grandchild options nested inside an optgroup
859
860
src/renderers/dom/shared/wrappers/__tests__/ReactDOMTextarea-test.js
861
* should allow setting `defaultValue`
src/renderers/dom/fiber/wrappers/ReactDOMFiberSelect.js
+7
@@ -153,6 +153,13 @@ var ReactDOMSelect = {
153
);
154
didWarnValueDefaultValue = true;
155
}
156
+
157
+ node.multiple = Boolean(props.multiple);
158
+ if (value != null) {
159
+ updateOptions(node, Boolean(props.multiple), value);
160
+ } else if (props.defaultValue != null) {
161
+ updateOptions(node, Boolean(props.multiple), props.defaultValue);
162
+ }
163
},
164
165
postUpdateWrapper: function(element : Element, props : Object) {