Skip to content

Commit 78942cd

Browse files
refactor(select): console warning if the option value data to be selected does not exist
1 parent 114f38b commit 78942cd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ export const Select: FunctionComponent<SelectProps> = (props) => {
8484
}
8585
}
8686

87+
// console warning if a consumer's passed in value does not match an option
88+
if (props.value) {
89+
const valueMatch = opts.some((opt) => opt.value === props.value);
90+
91+
if (!valueMatch) {
92+
console.error(
93+
`Qwik UI: the provided option value "${props.value}" does not match any of the option values in the Select.`,
94+
);
95+
}
96+
}
97+
8798
return (
8899
<SelectImpl {...rest} _valuePropIndex={valuePropIndex} _options={opts}>
89100
{props.children}

0 commit comments

Comments
 (0)