Skip to content

Restore opener focus for saved-run objective dialog (Escape and reopen) - #3938

Merged
Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
jay23606:pr-go/3915-bug-saved-run-technique-and-objective-di
Nov 8, 2026
Merged

Roman Lutz (romanlutz) merged 2 commits into
microsoft:mainfrom
jay23606:pr-go/3915-bug-saved-run-technique-and-objective-di

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

The bug

Closing the saved-run Objectives detail dialog did not return keyboard focus to the objective button that opened it.

The change

This change adds regression tests for the objective dialog's focus behaviour. It also changes ScenarioRunPage.tsx, which adds closeObjective and rewires onClose to it. The fix in the prior commit (closeObjective restores focus to objectiveTrigger after the dialog closes) covers Close and Escape, since both route through onClose.

  • Adds a test for Escape close followed by reopening and a second Escape close.
  • Adds a test that Escape on the attack-details (Techniques) dialog returns focus to its opener.

How it was tested

  • cd frontend && npx jest src/components/Scenarios/ScenarioRunPage.test.tsx -t "restores focus": 4 passed.
  • cd frontend && npx jest src/components/Scenarios/ScenarioRunPage.test.tsx: 37 passed.
  • With ScenarioRunPage.tsx from the base commit, the same -t "restores focus" run exited 1 with 2 failed and 2 passed.

Not verified: real-browser focus behaviour (jsdom only), and the Techniques dialog path beyond its existing jsdom test. The issue's original repro used a headed/headless Chrome setup that was not rerun here.

Regression test: fails on base twice (/Expected element with focus/), passes on fix twice (cd frontend && npx jest src/components/Scenarios/ScenarioRunPage.test.tsx -t "restores focus to the objective opener")

Refs #3915

Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:12

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.

🟢 Approval recommended

No active review issues block approval of the dialog focus-restoration change.

No open issues 🎉

What changed in this PR

Restores keyboard focus to the opening objective button when saved-run Objective details are dismissed, addressing the objective-dialog portion of #3915.

Changes:

  • Routes objective-dialog closure through a handler that restores focus on the next animation frame, provided the opener remains connected.
  • Adds regression tests for objective Close, Escape, and reopening, plus Escape focus restoration for technique attack details.
File Description
frontend/​src/​components/​Scenarios/​ScenarioRunPage.tsx Adds and wires the objective-dialog focus restoration handler.
frontend/​src/​components/​Scenarios/​ScenarioRunPage.test.tsx Adds focus restoration coverage for objective and technique dialogs.

Review effort: Balanced

@romanlutz Roman Lutz (romanlutz) self-assigned this Nov 7, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 8, 2026
Merged via the queue into microsoft:main with commit afc7ab5 Nov 8, 2026
55 checks passed
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.

3 participants