Bug report
Current Behavior
When rendering a page (with cmd + r to reload for example), the input value is invisible for a split second before rendering, causing a flicker.
Loom: https://www.loom.com/share/bdc8acfded9e4cc8841a172d5cf16c64
Expected behavior
No flicker for rendering with default values.
Reproducible example
import * as SelectRadix from '@radix-ui/react-select';
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
import { useState } from 'react';
import { Link } from 'react-router';
import { toast } from 'sonner';
export function RadixForm() {
const [email, setEmail] = useState('m@example.com');
function handleSubmit(e: React.FormEvent) {
e.preventDefault();
toast({
title: 'You submitted the following values (Radix):',
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">
{JSON.stringify({ email }, null, 2)}
</code>
</pre>
),
});
}
return (
<form onSubmit={handleSubmit} className="w-2/3 space-y-6">
<div>
<label className="block text-sm font-medium text-gray-700">
Email (Radix Select)
</label>
<SelectRadix.Root value={email} onValueChange={setEmail}>
<SelectRadix.Trigger
className="RadixSelectTrigger"
aria-label="Email"
>
<SelectRadix.Value placeholder="Select a verified email to display" />
<SelectRadix.Icon className="RadixSelectIcon">
<ChevronDownIcon />
</SelectRadix.Icon>
</SelectRadix.Trigger>
<SelectRadix.Portal>
<SelectRadix.Content className="RadixSelectContent">
<SelectRadix.ScrollUpButton className="RadixSelectScrollButton">
<ChevronUpIcon />
</SelectRadix.ScrollUpButton>
<SelectRadix.Viewport className="RadixSelectViewport">
<SelectRadix.Item
className="RadixSelectItem"
value="m@example.com"
>
<SelectRadix.ItemText>m@example.com</SelectRadix.ItemText>
<SelectRadix.ItemIndicator className="RadixSelectItemIndicator">
<CheckIcon />
</SelectRadix.ItemIndicator>
</SelectRadix.Item>
<SelectRadix.Item
className="RadixSelectItem"
value="m@google.com"
>
<SelectRadix.ItemText>m@google.com</SelectRadix.ItemText>
<SelectRadix.ItemIndicator className="RadixSelectItemIndicator">
<CheckIcon />
</SelectRadix.ItemIndicator>
</SelectRadix.Item>
<SelectRadix.Item
className="RadixSelectItem"
value="m@support.com"
>
<SelectRadix.ItemText>m@support.com</SelectRadix.ItemText>
<SelectRadix.ItemIndicator className="RadixSelectItemIndicator">
<CheckIcon />
</SelectRadix.ItemIndicator>
</SelectRadix.Item>
</SelectRadix.Viewport>
<SelectRadix.ScrollDownButton className="RadixSelectScrollButton">
<ChevronDownIcon />
</SelectRadix.ScrollDownButton>
</SelectRadix.Content>
</SelectRadix.Portal>
</SelectRadix.Root>
<p className="mt-2 text-sm text-gray-500">
You can manage email addresses in your{' '}
<Link to="/examples/forms" className="text-blue-600 hover:underline">
email settings
</Link>
.
</p>
</div>
<button type="submit">Submit</button>
</form>
);
}
export default function Test() {
return (
<div className="space-y-12 p-4">
<div>
<h2>Radix Form</h2>
<RadixForm />
</div>
</div>
);
}
Suggested solution
Make it so there are no side-effects setting the value, but instead the value is set from the start.
Additional context
N/A
Your environment
| Software |
Name(s) |
Version |
| Radix Package(s) |
@radix-ui/react-select |
2.1.6 |
| React |
n/a |
19.0.0 |
| Browser |
Brave |
1.76.74 (Chromium: 134.0.6998.89) (arm64) |
| Assistive tech |
None specified |
N/A |
| Node |
n/a |
22.14.0 |
| npm/yarn |
npm |
10.9.2 |
| Operating System |
macOS |
15.3.2 (Build 24D81) |
Bug report
Current Behavior
When rendering a page (with
cmd + rto reload for example), the input value is invisible for a split second before rendering, causing a flicker.Loom: https://www.loom.com/share/bdc8acfded9e4cc8841a172d5cf16c64
Expected behavior
No flicker for rendering with default values.
Reproducible example
Suggested solution
Make it so there are no side-effects setting the value, but instead the value is set from the start.
Additional context
N/A
Your environment