-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Description
I would like to report my bug #2803 again please, because it was closed, and @gaearon said "re-open it if it's still a problem."
As I currently understand it, React is incorrectly handling a common case in the construction of <select>
s. It is fairly normal to create a <select>
where the first element is disabled, but remains pre-selected.
React should render this case, but instead renders the first deselected control.
I attempted to fix this by forcing the selection. The normal approach is to set selected
on the relevant <option>
, but React disallows this, preferring a novel property defaultValue
on the <select>
instead, mimicing a first-write version of the <select>
property value
.
If you attempt to set defaultValue
, what you set is ignored (it may be the case that defaultValue is broken on select.)
React's inability to render a disabled <option>
as either the default or selected initial has been present since at least sometime mid-version-14, which is when I first found it. I first documented it in 15.3.1 in January 2015, because prior to then it was faster to tell the core devs on IRC. I do not know how far it goes back past mid-r14.