Skip to content

React 16 continues to incorrectly handle disabled <options> as #2803 #11100

@StoneCypher

Description

@StoneCypher

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions