Skip to content

Commit de008b1

Browse files
fix(select): if every option in the select is disabled, we throw an error
1 parent 8994c3c commit de008b1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/website/src/routes/docs/headless/select/examples/uncontrolled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default component$(() => {
1111
const usersSig = useSignal<string[]>(['Tim', 'Ryan', 'Jim', 'Jessie', 'Abby']);
1212

1313
return (
14-
<Select value="Jessie" class="relative min-w-40">
14+
<Select value="Jessi" class="relative min-w-40">
1515
<SelectTrigger class="w-full border-2 border-dashed border-red-400">
1616
<SelectValue placeholder="Select an option" />
1717
</SelectTrigger>

packages/kit-headless/src/components/select/select-inline.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ export const Select: FunctionComponent<SelectProps> = (props) => {
5555
}
5656
}
5757

58-
// TODO: will have problems if all options are disabled
5958
if (isDisabledArr[valuePropIndex] === true) {
6059
valuePropIndex = isDisabledArr.findIndex((isDisabled) => isDisabled === false);
60+
if (valuePropIndex === -1) {
61+
throw new Error(
62+
`Qwik UI: it appears you've disabled every option in the select. Was that intentional?`,
63+
);
64+
}
6165
}
6266

6367
return (

0 commit comments

Comments
 (0)