Skip to content

Commit 2bd2675

Browse files
select fixes (#1057)
* select fixes * changeset --------- Co-authored-by: thejackshelton <[email protected]>
1 parent 8c07955 commit 2bd2675

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.changeset/popular-cups-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik-ui/headless': patch
3+
---
4+
5+
fix: select uses correct types and does not execute focus on server side

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ export const HSelectRoot: Component<SelectProps & InlineCompProps> = (
8585
// distinct value, or the display value is the same as the value
8686
const value = (givenItemValue !== null ? givenItemValue : displayValue) as string;
8787

88-
itemsMap.set(currItemIndex, { value, displayValue, disabled: isItemDisabled });
88+
itemsMap.set(currItemIndex, {
89+
value,
90+
displayValue,
91+
disabled: isItemDisabled,
92+
});
8993

9094
if (props.value && props.multiple) {
9195
throw new Error(
@@ -99,7 +103,9 @@ export const HSelectRoot: Component<SelectProps & InlineCompProps> = (
99103
valuePropIndex = currItemIndex;
100104
}
101105

102-
const isString = typeof child.props.children === 'string';
106+
const isString =
107+
typeof child.props.children === 'string' ||
108+
typeof child.props.children === 'object';
103109

104110
if (!isString) {
105111
throw new Error(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export const HSelectItem = component$<SelectItemProps>((props) => {
6161
if (disabled) return;
6262

6363
if (context.highlightedIndexSig.value === _index) {
64-
itemRef.value?.focus({ preventScroll: true });
64+
if (!isServer) {
65+
itemRef.value?.focus({ preventScroll: true });
66+
}
6567
return true;
6668
} else {
6769
return false;

0 commit comments

Comments
 (0)