Skip to content

fix: restore focus on toast dismiss - #10260

Merged
mikeharv merged 1 commit into
RaspberryPiFoundation:mainfrom
mikeharv:toast-focus
Aug 11, 2026
Merged

fix: restore focus on toast dismiss#10260
mikeharv merged 1 commit into
RaspberryPiFoundation:mainfrom
mikeharv:toast-focus

Conversation

@mikeharv

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #8912

Proposed Changes

When a toast is dismissed via the close button, focus is restored to the node that was focused before the close button took focus, instead of always calling workspace.markFocused().

Screen.Recording.2026-08-11.at.12.39.27.PM.mov

To do this, a new FocusManager.getPreviouslyFocusedNode() method was created. We fall back to focusTree(workspace) if there is no focsuable previous node, so focus is parked on the workspace through FocusManager.

Reason for Changes

Previously, manually dismissing a toast always focused the workspace SVG. If the user had a block or other node focused, that context was lost.

Test Coverage

  • focus_manager_test.js: getPreviouslyFocusedNode() gets a basic unit test
  • toast_test.js new suite:
    • Restores a previously focused block after closing the toast.
    • Falls back to the workspace focus target when nothing was previously focused.

@mikeharv
mikeharv requested a review from a team as a code owner August 11, 2026 16:41
@mikeharv
mikeharv requested a review from gonfunko August 11, 2026 16:41
@github-actions github-actions Bot added the PR: fix Fixes a bug label Aug 11, 2026
@mikeharv
mikeharv merged commit 844dd25 into RaspberryPiFoundation:main Aug 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve focus behavior when manually dismissing a toast.

2 participants