Select: closed trigger keeps the first label it learned; a changed item label never shows
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start in foundation/lists/listbox-value.js, where selection.learn runs only on the first call and listbox.remember caches the label. Reproduce with the Select example in the issue, where the trigger keeps showing Unknown · 0 after the item label changes. Done means the closed SelectValue shows the selected item's current label, and a test covers a label that changes while the list is closed. Choosing when to re-learn is a design decision, so confirm the approach with maintainers first.
Written by the indexing model from the issue text.
Description
@ui-sdk/core 0.1.0-beta.2, Select: while the list is closed, the trigger keeps the label it first learned for the selected value. When that item's label changes later (a count in it, a name that depends on another field), SelectValue still shows the old text until the list is opened.
Cause: selection.learn (foundation/lists/listbox-value.js) runs once ("Only the first call looks") and listbox.remember caches the label; the items are not mounted while closed, so nothing updates it.
Repro
function Demo() {
const [n, setN] = useState(0)
return (
<>
<Select defaultValue="a">
<SelectTrigger><SelectValue /></SelectTrigger>
<SelectContent><SelectItem value="a">Unknown · {n}</SelectItem></SelectContent>
</Select>
<button onClick={() => setN(n + 1)}>+1</button>
</>
)
}
Press +1: the trigger still says Unknown · 0. A native <select> shows Unknown · 1.
Expected: the closed trigger shows the selected item's current label, as a native select does.
Workaround we use: itemToLabel from the current children, and a SelectValue render function returning that label.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 122
- Avg merge
- 3h 12m
- Merged PRs (30d)
- 437
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel-labs/ui
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vercel-labs/ui#540 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vercel-labs/ui#525 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vercel-labs/ui#521 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vercel-labs/ui#515 ·
Maintainers usually reply within 1 day
-
`checkPattern('checkbox')` on a `CheckboxGroup` reports the group's own hidden form input as unnamedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vercel-labs/ui#512 ·
Maintainers usually reply within 1 day
Similar issues
-
area: web
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
inabagumi/shinju-date#6823 ·
Maintainers usually reply within 1 day
-
accepted ai-dev ai-implementing
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
livesport/homer#218 · 1 comment ·
Maintainers usually reply within 1 day
-
normalizePropName strips `#` characters from Figma property names instead of only the `#id` suffixOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
figma/code-connect#419 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day