Skip to content

React Select changes value to '' on render #3693

@AbdUlHamedMaree

Description

@AbdUlHamedMaree

Bug report

Current Behavior

React Select triggeres the onValueChange event on render and the value is an empty string ''

Expected behavior

It shouldn't change the value by it's own

Reproducible example

CodeSandbox

Suggested solution

  • not wrapping the select in form element
  • rendering the select even with no data
  • not setting data on render

Additional context

to trigger the issue you should have this flow:

  • the select is placed inside a form
  • you should load data from somewhere and the select should not be rendered while loading the data
  • when data is loaded you will show the select and set the value of it
    if one of those conditions doesn't match, the issue will not appear

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-select 2.2.6
React n/a >=17
Browser Edge 141.0.3537.57
Assistive tech NextJs and CRA 15.5.2and 3.3.0
Node n/a 22
npm/yarn/pnpm npm 10.9.3
Operating System Windows 11 Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions