We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select should accept the controlled value without spontaneously resetting it to blank. Console observed in React 18:
export function SelectTest() { const [value, setValue] = useState('1') console.log('value:', value) const options = [ { value: '1', label: 'Option 1' }, { value: '2', label: 'Option 2' }, ] useEffect(() => { console.log('resetting to 2') setValue('2') }, []) const onChange = (value: string) => { console.log('onChange:', value) setValue(value) } return ( <Select.Root value={value} onValueChange={onChange}> <Select.Trigger className="flex w-20 justify-between border border-ui-accent bg-ui-blank"> <Select.Value /> <Select.Icon /> </Select.Trigger> <Select.Portal> <Select.Content className="border border-ui-accent bg-ui-blank"> <Select.Viewport> {options.map((option) => ( <Select.Item key={option.value} value={option.value}> <Select.ItemText>{option.value}</Select.ItemText> <Select.ItemIndicator /> </Select.Item> ))} </Select.Viewport> </Select.Content> </Select.Portal> </Select.Root> ) }
This issue only occurs when using React 19. The above code has been tested on React 18 with no issue
The text was updated successfully, but these errors were encountered:
This issue is actually the fault of React 19 improperly handling select inputs inside form tags. See React issue 30580
Sorry, something went wrong.
No branches or pull requests
Bug report
Current Behavior
Expected behavior
Select should accept the controlled value without spontaneously resetting it to blank. Console observed in React 18:
Reproducible example
Additional context
This issue only occurs when using React 19. The above code has been tested on React 18 with no issue
Your environment
The text was updated successfully, but these errors were encountered: