Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

select fixes #1057

Merged
merged 2 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/popular-cups-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik-ui/headless': patch
---

fix: select uses correct types and does not execute focus on server side
10 changes: 8 additions & 2 deletions packages/kit-headless/src/components/select/select-inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export const HSelectRoot: Component<SelectProps & InlineCompProps> = (
// 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(
Expand All @@ -99,7 +103,9 @@ export const HSelectRoot: Component<SelectProps & InlineCompProps> = (
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(
Expand Down
4 changes: 3 additions & 1 deletion packages/kit-headless/src/components/select/select-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const HSelectItem = component$<SelectItemProps>((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;
Expand Down
Loading