Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Fix Select controlled warning

Abi Raja3b4631798598
diff --git a/frontend/src/components/settings/OutputSettingsSection.tsx b/frontend/src/components/settings/OutputSettingsSection.tsx
index f684bd9d..0f78cede 100644
--- a/frontend/src/components/settings/OutputSettingsSection.tsx
+++ b/frontend/src/components/settings/OutputSettingsSection.tsx
@@ -4,6 +4,7 @@ import {
SelectGroup,
SelectItem,
SelectTrigger,
+ SelectValue,
} from "../ui/select";
import { Stack } from "../../lib/stacks";
import StackLabel from "../core/StackLabel";
@@ -26,7 +27,7 @@ function OutputSettingsSection({
<div className="grid grid-cols-3 items-center gap-4">
<span>{label}</span>
<Select
- value={stack}
+ value={stack ?? ""}
onValueChange={(value: string) => setStack(value as Stack)}
disabled={shouldDisableUpdates}
>
@@ -35,7 +36,7 @@ function OutputSettingsSection({
id="output-settings-js"
data-testid="stack-select"
>
- {stack ? <StackLabel stack={stack} /> : "Select a stack"}
+ <SelectValue placeholder="Select a stack" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
diff --git a/frontend/src/components/ui/select.tsx b/frontend/src/components/ui/select.tsx
index cdfb8ce2..497710a8 100644
--- a/frontend/src/components/ui/select.tsx
+++ b/frontend/src/components/ui/select.tsx
@@ -13,7 +13,20 @@ const Select = SelectPrimitive.Root
const SelectGroup = SelectPrimitive.Group
-const SelectValue = SelectPrimitive.Value
+// Avoid raw text nodes so browser translation extensions don't desync Radix's DOM bookkeeping.
+const SelectValue = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Value>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Value>
+>(({ placeholder, ...props }, ref) => (
+ <SelectPrimitive.Value
+ ref={ref}
+ placeholder={
+ typeof placeholder === "string" ? <span>{placeholder}</span> : placeholder
+ }
+ {...props}
+ />
+))
+SelectValue.displayName = SelectPrimitive.Value.displayName
const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
@@ -131,7 +144,9 @@ const SelectItem = React.forwardRef<
<CheckIcon className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
- <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ <SelectPrimitive.ItemText>
+ {typeof children === "string" ? <span>{children}</span> : children}
+ </SelectPrimitive.ItemText>
</SelectPrimitive.Item>
))
SelectItem.displayName = SelectPrimitive.Item.displayName