Skip to content

Variables: Fix multi value picker leaving the variable out of sync when clearing - #1631

Merged
ivanortegaalba merged 9 commits into
mainfrom
ivan/fix-multi-variable-clear-resync
Aug 28, 2026
Merged

Variables: Fix multi value picker leaving the variable out of sync when clearing#1631
ivanortegaalba merged 9 commits into
mainfrom
ivan/fix-multi-variable-clear-resync

Conversation

@ivanortegaalba

@ivanortegaalba ivanortegaalba commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Clearing every selected value left the picker and the variable disagreeing.

  • The clear button does not focus the input, so onBlur never fired and the clear was never committed: the picker showed Select value while the variable, the URL and the panels kept the previous values. The clear is now committed on change.
  • The picker owned a copy of the value for its whole lifetime, so it could keep rendering a stale selection. It now owns the value only while an edit is in progress.

Falling back to All (or to the first option when defaultToAll is false) on an empty selection is unchanged.

…lection

VariableValueSelectMulti keeps the selection in local state and commits it on blur,
then relies on a state change from the variable to re-sync. changeValueTo rewrites an
empty selection back to the default and early-returns when that rewrite equals the value
the variable already had, so nothing is published and the picker keeps rendering the
empty local state while the variable still holds its old value.

Re-sync the local state from the variable after committing.
… edit ends

Instead of re-reading the variable after committing, the local state now means "there is
an edit in flight" rather than "a copy of the value". It is undefined whenever the user is
not mid-edit, and the picker renders the variable's value directly, so the two cannot drift
apart and the variable is free to reject or rewrite what gets committed.
Clicking the clear button does not focus the input, so onBlur never fired and the clear was never committed: the picker showed the placeholder while the variable, the URL and the panels kept the previous values.
@ivanortegaalba
ivanortegaalba requested a review from a team as a code owner August 27, 2026 16:16
@ivanortegaalba
ivanortegaalba requested review from harisrozajac and mdvictor and removed request for a team August 27, 2026 16:16
@ivanortegaalba ivanortegaalba added patch Increment the patch version when merged release Create a release when this pr is merged labels Aug 28, 2026
@ivanortegaalba
ivanortegaalba merged commit 15520c1 into main Aug 28, 2026
19 checks passed
@ivanortegaalba
ivanortegaalba deleted the ivan/fix-multi-variable-clear-resync branch August 28, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged release Create a release when this pr is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants