Skip to content

fix(combobox): cache management for option values and labels #698

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025

Conversation

jzempel
Copy link
Member

@jzempel jzempel commented Jul 8, 2025

Description

Lack of memoized variable coordination presented a corner-case bug for consumers where value-label affinity could be lost. For example:

a multiselect combobox is rendered with possible options of [{ label: A, value: Apple }], then updated with [{ label: A, value: Apple }, { label: B, value: Basil }]. With a selectionValue of [ Apple, Basil ], these should map to show the labels "A" and "B". However, on first load it shows "A" (label) and "Basil" (value) instead as it’s stuck with the initial options despite the updated ones

Detail

The updated code moves previously memoized option labels, selectedValues, disabledValues, and hiddenValues into an object cache along with values. By removing the coordination, these values can be collectively reinitialized (and memoized) every time the combobox options change.

@jzempel jzempel requested a review from a team as a code owner July 8, 2025 19:03
@coveralls
Copy link

Coverage Status

coverage: 94.811% (-0.1%) from 94.958%
when pulling 79608db on jzempel/combobox-labels
into 0cdb148 on main.

Copy link
Contributor

@ze-flo ze-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever fix!

@jzempel jzempel merged commit d595d7e into main Jul 9, 2025
4 checks passed
@jzempel jzempel deleted the jzempel/combobox-labels branch July 9, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants