Skip to content

fix(combobox): resolve reactive item labels instead of stringifying them - #1185

Open
harshasiddartha wants to merge 1 commit into
qwikifiers:mainfrom
harshasiddartha:fix/combobox-object-in-input
Open

harshasiddartha wants to merge 1 commit into
qwikifiers:mainfrom
harshasiddartha:fix/combobox-object-in-input

Conversation

@harshasiddartha

Copy link
Copy Markdown

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests
  • Other

Why is it needed?

Fixes #1184

Selecting an item in the headless Combobox writes [object Object] into the input whenever the item label is a reactive expression.

Root cause

combobox-inline-comp.tsx builds the items map at pre-render time and casts the label's children straight to a string:

const displayValue = labelProps.children as string;

That holds for a literal (<Combobox.ItemLabel>Apple</Combobox.ItemLabel>), but when the label comes from a reactive expression - e.g. {user.label} where user comes from a useStore - the optimizer turns those children into a derived signal. The cast lies, and the signal object is what gets written to inputRef.value.value in selectionManager$. I confirmed this by decoding the Qwik state of a rendered page: the map entries serialize with Qwik's derived-signal marker (�n! label) rather than as strings.

The same bad value also flows into the default filter (displayValue.toLowerCase() in combobox-item.tsx), so filtering silently breaks for those items too.

Fix

Unwrap the children before storing the display value: resolve signals (recursively), join arrays of children, and stringify the rest. String labels take exactly the same path as before, so this is backwards compatible.

Verification

Added a store example (items whose labels come from a store) and a regression test in combobox.test.ts. It fails on main and passes with the fix:

  ✓  1 [logic] › combobox.test.ts:683:5 › Props › option value › GIVEN a combobox whose item labels come from a store
        WHEN an option is selected
        THEN the input displays the item label instead of "[object Object]" (758ms)

  1 passed (2.7s)

Full combobox suite (--retries=2 --workers=1): 69 passed, 2 flaky, 1 failed. The one failure - combobox.test.ts:253 (the latest selected option should be highlighted when the menu is opened again) - also fails on unmodified main on my machine, so it is pre-existing and unrelated to this change. nx lint headless and nx build headless both pass.

Note: select-inline.tsx has the same child.props.children as string cast and is likely affected by the same problem, but I left it out to keep this PR scoped to the reported issue. Happy to follow up.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have ran pnpm change and documented my changes
  • I have add necessary docs (if needed)
  • Added new tests to cover the fix / functionality

@changeset-bot

changeset-bot Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 82cac1d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@harshasiddartha

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@Sebosek

Sebosek commented Aug 19, 2026

Copy link
Copy Markdown

Hi, how long does it usually take to have the fix released?

@harshasiddartha
harshasiddartha force-pushed the fix/combobox-object-in-input branch from a74259b to 82cac1d Compare September 27, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐞] After selecting an item in Combobox, an object is set in input instead of text

2 participants