Skip to content

fix: close menus on Escape and on a click on the empty top bar - #1034

Merged
EtienneLescot merged 2 commits into
mainfrom
fix/1009-1015-menu-dismissal
Oct 6, 2026
Merged

EtienneLescot merged 2 commits into
mainfrom
fix/1009-1015-menu-dismissal

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Empty top bar (#1009)

  • The top bar is the window's drag region. The OS takes a press there as a caption click, so the page never saw the mousedown that closes the wordmark menu or the presets popover.
  • While one of the bar's menus is open, the bar drops its drag region. The first click closes the menu, the next one drags.

Escape (#1015)

  • The wordmark menu heard Escape only with focus inside it, and a press on its padding drops focus to <body>. It now listens on the document like the dialogs, refocuses the trigger and stops the key.
  • HUD popovers: Escape hands focus back to the button that opened them, instead of <body>.
  • The HUD language menu and the colour popover already closed on Escape in Chromium. The colour popover gets a regression test.

Related issue

Closes #1009
Part of #1015. Left open: keyboard navigation in the HUD language menu, and a macOS check of Escape on the HUD and the colour popover, which did not reproduce in Chromium.

Type of change

  • Bug fix

Release impact

  • Patch

Desktop impact

  • Not platform-specific

Testing

  • 8 new tests across 7 files (184 pass); both tsc configs; Biome.
  • Headless Edge on the browser shim: Escape and focus return on all three surfaces, and the header's computed app-region is no-drag while a menu is open.
  • Not done: a real Windows caption click, real OS keyboard on macOS.

🤖 Generated with Claude Code

The top bar is the window's drag region, and the OS takes a press there as
a caption click that never reaches the page, so the document mousedown that
closes the wordmark menu (and the presets popover) missed it. The bar now
drops its drag region while one of its menus is open.

Fixes #1009
The wordmark menu listened for Escape on its own element, so the key went
unheard once focus had left it: a press on the menu's padding or a
separator drops focus to <body>. It now listens on the document, as the
dialogs do, hands focus back to the trigger and stops the key there.

The HUD popovers already closed on Escape, but dropped focus to <body>
when it was inside them; it now goes back to the button that opened them.
The colour popover (Radix) already closes and refocuses its swatch; a
test pins it.

Fixes #1015
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c40a998f-4165-4d08-848e-492d7de65a48
📥 Commits

Reviewing files that changed from the base of the PR and between 8f3046c and 458689e.

📒 Files selected for processing (7)
  • src/components/ai-edition/ColorField.test.tsx
  • src/components/ai-edition/v4/EditorShellV4.module.css
  • src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsx
  • src/components/ai-edition/v4/EditorTopBar.test.tsx
  • src/components/ai-edition/v4/EditorTopBar.tsx
  • src/components/launch/LaunchWindow.test.tsx
  • src/components/launch/LaunchWindow.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Editor menus and launch popovers now restore focus to their triggers when Escape closes them. The editor top bar disables its drag region while a menu is expanded. Tests cover these interactions and color-picker focus restoration.

Changes

Popover dismissal and focus behavior

Layer / File(s) Summary
Editor popover dismissal and drag-region behavior
src/components/ai-edition/ColorField.test.tsx, src/components/ai-edition/v4/EditorShellV4.module.css, src/components/ai-edition/v4/EditorTopBar.tsx, src/components/ai-edition/v4/EditorTopBar.test.tsx, src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsx
AppMenu handles Escape at the document level, prevents its default action and propagation, closes, and restores focus to its trigger. The top bar has a no-drag condition when a descendant has aria-expanded="true". Tests cover menu and color-picker dismissal, focus, and the drag-region condition.
Launch popover Escape dismissal
src/components/launch/LaunchWindow.tsx, src/components/launch/LaunchWindow.test.tsx
Escape handling focuses the language-menu or device-settings trigger before closing the popover. Tests check focus return and verify that Escape does not change the locale.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: my-denia

Merge Risk: ⚪ Minimal · up to 45868

The identified focus concern does not block merging. Real Windows caption-click behavior remains unverified, but no failure has been established.

🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive The diff also changes Escape handling and focus return in EditorTopBar.tsx, LaunchWindow.tsx, and ColorField.test.tsx. The PR description associates this work with #1015, but the supplied linked… Provide the status, linkage, and coding requirements for #1015 so the Escape and focus-return changes can be assessed for scope.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: Escape dismissal and clicks on the empty top bar closing menus.
Description check ✅ Passed The description explains the changes, links the related issues, identifies the change type and release impact, and reports testing and limitations. It provides enough detail to assess the pull request…
Linked Issues check ✅ Passed #1009 requires an empty top-bar click to close the wordmark menu. EditorShellV4.module.css applies app-region: no-drag when a top-bar descendant has aria-expanded="true", so the click can reach …
Full details: Out of Scope Changes check

Explanation

The diff also changes Escape handling and focus return in EditorTopBar.tsx, LaunchWindow.tsx, and ColorField.test.tsx. The PR description associates this work with #1015, but the supplied linked-issue details include only #1009. I cannot establish whether these changes fit another active issue's scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EtienneLescot
EtienneLescot merged commit 01978b8 into main Oct 6, 2026
19 checks passed
@EtienneLescot
EtienneLescot deleted the fix/1009-1015-menu-dismissal branch October 6, 2026 15:32
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.

[Bug]: Wordmark menu does not close on a click on the empty top bar (Windows drag region)

1 participant