fix(Suggestion): preserve controlled input value - #5200
Open
olemartinorg wants to merge 1 commit into
Open
Conversation
Suggestion writes proposed single selections directly into its input before a controlled parent accepts them. Consumers that defer or reject changes therefore show state that disagrees with their selected prop and can emit a follow-up empty selection while reconciling. Let the existing selected-item reconciliation update the input after the parent accepts a value. Cover both deferred selections and accepted prop updates so controlled state remains authoritative without losing input synchronization.
🦋 Changeset detectedLatest commit: 1ef5825 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
olemartinorg
marked this pull request as ready for review
August 14, 2026 11:55
olemartinorg
requested review from
Barsnes,
eirikbacker and
mimarz
as code owners
August 14, 2026 11:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keep a controlled Suggestion input synchronized with its accepted
selectedprop when a consumer defers or rejects a proposed selection.The single-selection synchronization added in #5043 writes the proposed option label directly into the input before calling
onSelectedChange. For controlled consumers, this makes the visible input disagree withselecteduntil the parent accepts the change. Consumers that deliberately defer acceptance—for example, to ask for confirmation—can then receive a follow-up empty selection while the component reconciles.This was discovered in Altinn/altinn-studio#19766 while upgrading Altinn Studio to Designsystemet 1.18.0/1.19.0. Altinn's Dropdown waits for confirmation before updating
selected; after confirmation, Suggestion emitted an empty change and reopened the confirmation popover with an empty option label.The existing selected-item reconciliation already updates the input when the controlled prop changes. This removes the premature write and adds React-wrapper tests for both rejected/deferred proposals and accepted prop updates.
Verification
Expected: Norway,Received: Sweden.