diff --git a/.changeset/popular-cups-study.md b/.changeset/popular-cups-study.md new file mode 100644 index 000000000..d84efdfb7 --- /dev/null +++ b/.changeset/popular-cups-study.md @@ -0,0 +1,5 @@ +--- +'@qwik-ui/headless': patch +--- + +fix: select uses correct types and does not execute focus on server side diff --git a/packages/kit-headless/src/components/select/select-inline.tsx b/packages/kit-headless/src/components/select/select-inline.tsx index 84e6b725b..7370193bf 100644 --- a/packages/kit-headless/src/components/select/select-inline.tsx +++ b/packages/kit-headless/src/components/select/select-inline.tsx @@ -85,7 +85,11 @@ export const HSelectRoot: Component = ( // distinct value, or the display value is the same as the value const value = (givenItemValue !== null ? givenItemValue : displayValue) as string; - itemsMap.set(currItemIndex, { value, displayValue, disabled: isItemDisabled }); + itemsMap.set(currItemIndex, { + value, + displayValue, + disabled: isItemDisabled, + }); if (props.value && props.multiple) { throw new Error( @@ -99,7 +103,9 @@ export const HSelectRoot: Component = ( valuePropIndex = currItemIndex; } - const isString = typeof child.props.children === 'string'; + const isString = + typeof child.props.children === 'string' || + typeof child.props.children === 'object'; if (!isString) { throw new Error( diff --git a/packages/kit-headless/src/components/select/select-item.tsx b/packages/kit-headless/src/components/select/select-item.tsx index b880ae1f6..c88d02ee5 100644 --- a/packages/kit-headless/src/components/select/select-item.tsx +++ b/packages/kit-headless/src/components/select/select-item.tsx @@ -61,7 +61,9 @@ export const HSelectItem = component$((props) => { if (disabled) return; if (context.highlightedIndexSig.value === _index) { - itemRef.value?.focus({ preventScroll: true }); + if (!isServer) { + itemRef.value?.focus({ preventScroll: true }); + } return true; } else { return false;