Skip to content

Commit 78b6c81

Browse files
fix(Select): display placeholder when value is empty string
The generic Select changes broke placeholder display when form values are initialized with empty strings. The condition 'value != null' returns true for empty strings, causing String(value) to display instead of the placeholder. Fixed by checking both null/undefined AND empty string conditions. Fixes failing test in select.stories.tsx that expected placeholder text to be displayed initially.
1 parent 06474b1 commit 78b6c81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/components/src/ui/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function Select<T extends React.Key = string>({
133133
aria-controls={listboxId}
134134
{...buttonProps}
135135
>
136-
{value != null ? (selectedOption?.label ?? String(value)) : placeholder}
136+
{value != null && value !== '' ? (selectedOption?.label ?? String(value)) : placeholder}
137137
<ChevronIcon className="w-4 h-4 opacity-50" />
138138
</Trigger>
139139
</PopoverTrigger>

0 commit comments

Comments
 (0)