Skip to content

fix(Suggestion): initialize the empty state - #5189

Open
olemartinorg wants to merge 1 commit into
digdir:mainfrom
olemartinorg:fix/suggestion-initial-empty-state
Open

fix(Suggestion): initialize the empty state#5189
olemartinorg wants to merge 1 commit into
digdir:mainfrom
olemartinorg:fix/suggestion-initial-empty-state

Conversation

@olemartinorg

Copy link
Copy Markdown
Contributor

Summary

Initialize Suggestion's empty-state visibility when its options are rendered, instead of waiting for the first input or selection event.

Root cause

PR #5097 changed Suggestion.Empty from conditionally rendered React content to a persistent option whose visibility is managed by handleEmpty. However, handleEmpty was only registered for input and comboboxafterselect events.

When a Suggestion initially rendered with selectable options, neither event had occurred yet. The empty option therefore remained visible alongside the real options until the user typed or selected something.

We discovered this while validating the Designsystemet upgrade in Altinn/altinn-studio#19766. Altinn's Dropdown ordering tests received the Norwegian “no results” message as the first option instead of the expected country. This blocks our progress validating the upgrades to Designsystemet 1.18.0 and 1.19.0.

Fix

Run the existing handleEmpty synchronization from Suggestion's mutation-driven render path. This covers initial and asynchronously rendered options while retaining the existing input and selection updates.

The regression test renders an empty-state option together with a selectable option and verifies that the empty state is hidden without requiring user interaction. It failed before the fix with empty.hidden === false.

Verification

  • biome check packages/web/src/suggestion/suggestion.ts packages/web/src/suggestion/suggestion.test.ts
  • Chromium Suggestion tests: 3 passed
  • pnpm build:web
  • Altinn Dropdown tests using the locally resolved Designsystemet packages: 12 passed

The creatable-button redesign made the empty option persistent and delegated
its visibility to input and selection events. Before either event occurs, a
Suggestion with available options can therefore show its no-results message
alongside those options.

Run the same empty-state synchronization from the existing mutation-driven
render path so initial and asynchronously rendered options start in the
correct state. Cover the initial render to prevent this event-order regression
from returning.
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 804ed42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@digdir/designsystemet-web Patch
@digdir/designsystemet Patch
@digdir/designsystemet-css Patch
@digdir/designsystemet-types Patch
@digdir/designsystemet-react Patch

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
olemartinorg marked this pull request as ready for review August 14, 2026 08:29
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.

1 participant