Skip to content

Restore focus after selecting dashboard menu items - #18862

Merged
Mitch Denny (mitchdenny) merged 3 commits into
microsoft:mainfrom
adamint:adamint/fix-17656-menu-focus-restoration
Jul 27, 2026
Merged

Restore focus after selecting dashboard menu items#18862
Mitch Denny (mitchdenny) merged 3 commits into
microsoft:mainfrom
adamint:adamint/fix-17656-menu-focus-restoration

Conversation

@adamint

@adamint Adam Ratzman (adamint) commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

Selecting an item from a dashboard button menu can leave keyboard focus on the page body. #17926 fixed the original Resources View Options case, but similar AspireMenuButton controls still reproduce the same issue.

This makes focus restoration the default for button-anchored menus. The trigger is focused before the item callback runs so callbacks that open a dialog or move focus elsewhere keep their intended focus.

User-facing usage

After selecting an item from a dashboard button menu, keyboard focus returns to the button that opened the menu instead of being lost.

Screenshots / Recordings

Grabacion.de.pantalla.2026-07-22.a.la.s.11.58.15.a.m.mov

Validation: Aspire.Dashboard.Components.Tests (185 passed).

Fixes #17656

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2e873eb1-f464-47b9-8eed-0d2dd7b2fe43
Copilot AI review requested due to automatic review settings July 22, 2026 15:48
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18862

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18862"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Makes keyboard-focus restoration the default for dashboard button menus.

Changes:

  • Defaults AspireMenuButton to restore trigger focus.
  • Restores focus before item callbacks run.
  • Updates component tests for default and opt-out behavior.
Show a summary per file
File Description
AspireMenuButton.razor.cs Enables focus restoration by default.
AspireMenu.razor.cs Reorders focus restoration before callbacks.
AspireMenuTests.cs Tests default restoration, ordering, and opt-out.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/Aspire.Dashboard/Components/Controls/AspireMenuButton.razor.cs
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No issues found. Reviewed the focus-restoration ordering, all AspireMenuButton call sites, the separate context-menu behavior, and regression coverage.

Covers the structured logs "Remove data" menu, an AspireMenuButton that
relies on the new default rather than opting in explicitly. Verified to
fail when RestoreFocusOnItemClick defaults back to false.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f9959eed-3415-4f0b-a9b4-3a2a1c87328b
Copilot AI review requested due to automatic review settings July 27, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

The azure-cosmos-emulator:stable image has a baked-in evaluation expiry
that has now passed, so the container exits with code 1 on start:

    Error: The evaluation period has expired.
    ./cosmosdb-emulator: ERROR: PAL initialization failed. Error: 104

This fails deterministically on every run and blocks unrelated PRs, so
disable it until a refreshed image is published.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f9959eed-3415-4f0b-a9b4-3a2a1c87328b
Copilot AI review requested due to automatic review settings July 27, 2026 02:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/Aspire.Dashboard/Components/Controls/AspireMenuButton.razor.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard focus moves out of page after selecting menu item from View options:A11y_Aspire Dashboard_Resources_Keyboard

4 participants