Skip to content

value= shouldn't be converted to defaultValue= for <option> #625

Closed
@philiptzou

Description

@philiptzou

The value of <option> tags of <select> are fixed. Converting their value= to defaultValue= results bug if the option label is different from the value. For example:

<select name="range" value="gte-2">
  <option value="lt-1">Less than 1</option>
  <option value="gte-2">≥2<option>
</select>

The value of <select>'s "gte-2" won't get a match and it will fallback to "Less than 1".

// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
// https://reactjs.org/docs/uncontrolled-components.html
if (
(propName === 'checked' || propName === 'value') &&
!inputIsValueOnly
) {
propName = getPropName('default' + attributeNameLowerCased);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions