Skip to content

Restore focus after selecting dashboard menu items#18862

Open
adamint wants to merge 1 commit into
microsoft:mainfrom
adamint:adamint/fix-17656-menu-focus-restoration
Open

Restore focus after selecting dashboard menu items#18862
adamint wants to merge 1 commit into
microsoft:mainfrom
adamint:adamint/fix-17656-menu-focus-restoration

Conversation

@adamint

@adamint 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
@adamint
adamint requested a review from JamesNK as a code owner 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.

@JamesNK JamesNK left a comment

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.

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

3 participants