You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When moving the pointer from an open web context submenu back onto the parent menu over a separator, disabled row, header, or menu padding, the entire context menu closes instead of closing only the submenu and keeping the parent menu open.
Hovering a submenu item focuses its button; re-entering the parent menu runs closeMenusFromLevel(1) and removes that submenu while it holds document.activeElement, dropping focus to document.body. workspaceFocus then focuses the composer and onFocusIn closes the menu (without workspace focus recovery, keyboard navigation stops working).
Change
In apps/web/src/contextMenuFallback.ts, closeMenusFromLevel(level) focuses menuStack[level - 1] ({ preventScroll: true }) before removing closing submenus whenever level > 0, menuStack.length > level, and document.activeElement is inside menuStack.slice(level). Focus stays inside the menu stack so focusout.relatedTarget is non-null, keeping the parent menu open and keyboard-usable. Added one focused Chromium browser test in apps/web/src/contextMenuFallback.keyboard.browser.test.ts.
Scope
Bug fix (focus loss and unintended dismissal in the web fallback context menu). Small, obvious fix in one module, so no tracking issue is needed. Web-only: desktop Electron uses native Electron.Menu (apps/web/src/localApi.ts), and mobile has no contextMenuFallback.
Verification
Setup. Ubuntu 26.04 (Linux x86_64), Chromium via Playwright debugging port, dark theme, 1280×800, fresh isolated data (T3CODE_DEV_SEED=0, Replay (dev)) on each commit.
Steps. Right-click Demo thread in sidebar → hover Snooze → hover In 1 hour → move pointer onto parent separator.
Leaving the Snooze submenu onto the parent separator dismisses the menu.
Leaving the Snooze submenu onto the parent separator keeps the parent menu open.
Links. Test apps/web/src/contextMenuFallback.keyboard.browser.test.ts
Not shown.
Desktop Electron and mobile (unaffected; neither uses showContextMenuFallback).
Repo-wide test suite and production build (left to CI).
Checks, regression test output, and interaction observations
Checked by AI agent on Linux (Node 26.13.1, pnpm 12.14.0).
Real-app observations (Chromium via Playwright debugging port):
Base 69934715051c: inSub{ levels: 2, activeTag: "BUTTON", activeRole: "menuitem", activeText: "In 1 hour1:58 AM" } → after leaving submenu to parent separator: { levels: 0, activeTag: "DIV", activeRole: "textbox" }.
Head e1137dd522c5: inSub{ levels: 2, activeTag: "BUTTON", activeRole: "menuitem", activeText: "In 1 hour2:09 AM" } → after leaving submenu to parent separator: { levels: 1, activeTag: "DIV", activeRole: "menu" } → ArrowDown focuses "New thread on main", Escape closes cleanly (levels: 0), hovering enabled sibling "Rename thread" keeps levels: 1 and focuses it, ArrowLeft from submenu returns to "Snooze", clicking outside dismisses (levels: 0).
Failing regression test on base 69934715051c (before applying the fix):
FAIL |@t3tools/web (browser) (chromium)| src/contextMenuFallback.keyboard.browser.test.ts > keeps focus on the parent menu when leaving a submenu onto a non-action area
AssertionError: expected <body>...</body> to be <div ... data-context-menu="true" data-level="0" role="menu">...</div>
Test Files 1 failed (1)
Tests 1 failed | 7 passed (8)
Macroscope's review found this PR approvable — The fallback context menu preserves focus on the parent before removing a focused submenu, preventing unintended dismissal. This is a narrowly scoped interaction fix with no persistent-data or external-system effects.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between e1137dd and 226be4e.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
When submenu levels close, focus returns to the preceding menu if the active element was within the levels being closed. A browser test checks continued parent-menu navigation and Escape behavior.
Changes: Context menu focus restoration
Layer / File(s)
Summary
Restore focus when closing submenu levels apps/web/src/contextMenuFallback.ts, apps/web/src/contextMenuFallback.keyboard.browser.test.ts
closeMenusFromLevel focuses the preceding menu when focus is within the submenu levels being closed. The browser test checks that the parent menu remains focused, ArrowDown focuses Rename, and Escape restores focus to the opener and resolves the result to null.
This fixes the web fallback context menu so that moving from a submenu onto a separator or other non-action area in the parent menu no longer closes the whole menu or loses keyboard focus. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(web): keep context menu open when leaving submenu onto parent menu" matches the main change. The diff focuses the parent menu in closeMenusFromLevel before removing closing submenus tha…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the bug, its reproduction steps, and the expected behavior. The Change section…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(web): keep context menu open when leaving submenu onto parent menu" matches the main change. The diff focuses the parent menu in closeMenusFromLevel before removing closing submenus that hold focus, so the parent menu stays open. The title uses a conventional commit prefix and names the affected area (web context menu). It is concise and specific.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the bug, its reproduction steps, and the expected behavior. The Change section explains the fix in contextMenuFallback.ts and names the added regression test. The Scope section states this is a bug fix, explains why no tracking issue is needed, and says the change is web-only. The Verification section gives the environment, before and after screenshots, a failing test on base, passing tests on head, and the check:changed output. It also lists what was not checked: desktop Electron, mobile, the repo-wide suite, and the production build. The description also ends with the model and harness used, as the template asks. Two minor issues: the before and after links point to different repositories (pingdotgg/t3code and only21mil/t3code), and the screenshots are hosted on a personal gist. Neither makes the description incomplete.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Environment: web, Chromium, 1280×800, light theme, fresh synthetic data on each commit.
Steps: right-click New thread → hover Snooze → hover In 1 hour → move directly to the parent separator between Snooze and Rename thread. On head, ArrowDown then focuses New thread on main.
Scenario: Returning from Snooze to the parent separator preserves the menu and keyboard navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When moving the pointer from an open web context submenu back onto the parent menu over a separator, disabled row, header, or menu padding, the entire context menu closes instead of closing only the submenu and keeping the parent menu open.
Hovering a submenu item focuses its button; re-entering the parent menu runs
closeMenusFromLevel(1)and removes that submenu while it holdsdocument.activeElement, dropping focus todocument.body.workspaceFocusthen focuses the composer andonFocusIncloses the menu (without workspace focus recovery, keyboard navigation stops working).Change
In
apps/web/src/contextMenuFallback.ts,closeMenusFromLevel(level)focusesmenuStack[level - 1]({ preventScroll: true }) before removing closing submenus wheneverlevel > 0,menuStack.length > level, anddocument.activeElementis insidemenuStack.slice(level). Focus stays inside the menu stack sofocusout.relatedTargetis non-null, keeping the parent menu open and keyboard-usable. Added one focused Chromium browser test inapps/web/src/contextMenuFallback.keyboard.browser.test.ts.Scope
Bug fix (focus loss and unintended dismissal in the web fallback context menu). Small, obvious fix in one module, so no tracking issue is needed. Web-only: desktop Electron uses native
Electron.Menu(apps/web/src/localApi.ts), and mobile has nocontextMenuFallback.Verification
Setup. Ubuntu 26.04 (Linux x86_64), Chromium via Playwright debugging port, dark theme, 1280×800, fresh isolated data (
T3CODE_DEV_SEED=0,Replay (dev)) on each commit.Steps. Right-click
Demo threadin sidebar → hoverSnooze→ hoverIn 1 hour→ move pointer onto parent separator.69934715051c)e1137dd522c5)Leaving the Snooze submenu onto the parent separator dismisses the menu.
Leaving the Snooze submenu onto the parent separator keeps the parent menu open.
Links. Test
apps/web/src/contextMenuFallback.keyboard.browser.test.tsNot shown.
showContextMenuFallback).Checks, regression test output, and interaction observations
Checked by AI agent on Linux (
Node 26.13.1,pnpm 12.14.0).Real-app observations (Chromium via Playwright debugging port):
69934715051c:inSub{ levels: 2, activeTag: "BUTTON", activeRole: "menuitem", activeText: "In 1 hour1:58 AM" }→ after leaving submenu to parent separator:{ levels: 0, activeTag: "DIV", activeRole: "textbox" }.e1137dd522c5:inSub{ levels: 2, activeTag: "BUTTON", activeRole: "menuitem", activeText: "In 1 hour2:09 AM" }→ after leaving submenu to parent separator:{ levels: 1, activeTag: "DIV", activeRole: "menu" }→ArrowDownfocuses"New thread on main",Escapecloses cleanly (levels: 0), hovering enabled sibling"Rename thread"keepslevels: 1and focuses it,ArrowLeftfrom submenu returns to"Snooze", clicking outside dismisses (levels: 0).Failing regression test on base
69934715051c(before applying the fix):Passing focused tests on head
e1137dd522c5:vp run check:changed 69934715051ceea6eb1a83891aa50635836a0793on heade1137dd522c5:Mergeability check (
git merge-tree --write-tree 69934715051ceea6eb1a83891aa50635836a0793 HEAD): clean (f644b5c957481b7a8c56ed6da31e83ea090b863d).Test delta:
{"kinds":{"browser":1,"server":0,"unit":0},"net":1,"newBrowserFiles":[]} quiet.Generated with Gemini 4 Neon in T3 Code Nightly