fix(web): block type-to-focus behind open dialogs - #8139
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughChatView now detects open alert-dialog, command-dialog, dialog, and sheet popups during type-to-focus behavior. ChangesChat focus behavior
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The change prevents type-to-focus from redirecting printable keys into the composer while supported dialogs are open, while preserving focus behavior for closed keep-mounted sheets. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38e9afe514
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
One finding: the new open-dialog selector list misses the mobile sidebar sheet, which overrides the sheet-popup slot, so type-to-focus still types into the composer behind it.
Posted via Macroscope — UI Consistency
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 38e9afe. Configure here.
There was a problem hiding this comment.
Verification
Reviewed against the actual sources, not just the diff. The fix is correct.
Premise confirmed. Nothing in apps/web renders data-slot="dialog" (exact match). All dialog primitives render suffixed slots (dialog-popup, alert-dialog-popup, dialog-viewport, etc.), so the old guard was dead code and printable keys could reach the composer behind any open dialog.
Selectors match the real DOM:
dialog-popup(ui/dialog.tsx:75),alert-dialog-popup(ui/alert-dialog.tsx:68),command-dialog-popup(ui/command.tsx:72),sheet-popup(ui/sheet.tsx:93) — all present.- The mobile sidebar overrides the popup slot with
data-slot="sidebar"+data-mobile="true"(ui/sidebar.tsx:242-254), so it would be missed by thesheet-popupselector. The dedicated fifth selector is needed and correct. The desktop sidebar never rendersdata-mobile="true", so it can't false-positive.
State filtering is correct and necessary. Verified against the installed @base-ui/react 1.5.0 (popupStateMapping.js): popups carry data-open when open, data-closed when closed, data-ending-style while animating out. Two consequences:
RightPanelSheetrenders akeepMountedSheetPopupthat stays in the DOM when closed. Without the:is([data-open],[data-ending-style])filter, that closed sheet would permanently block type-to-focus. The filter handles it — closed keep-mounted popups only carrydata-closed.- During exit transitions the popup has
data-closed+data-ending-style, so the guard survives close animations.data-openis present during enter (data-starting-styleis additive), so entering isn't missed either.
Coverage is complete. Inventoried every *-popup slot in apps/web: interactive layers (dialog, alert-dialog, command-dialog, sheet, menu, select, popover, combobox, autocomplete) are all in the list. tooltip-popup and toast-popup are correctly excluded — passive/hover-only surfaces shouldn't block typing.
Non-blocking suggestions
-
A regression test would have caught the original bug. The defect class here is "selector silently rotted" —
[data-slot="dialog"]matched nothing and no test noticed. A small unit test forshouldTypeToFocusComposerasserting (a)falsewith an opendialog-popupin the document, and (b)truewith a keep-mounted closedsheet-popup(data-closedonly) would pin both the fix and the subtle state-filter contract. The PR only re-runs existing suites. -
LAUNCHER_SHORTCUT_BLOCKING_LAYERS(RightPanelTabs.tsx:107) now drifts further. That parallel list has nosheet-popup/mobile-sidebar entries and no state filtering, so launcher letter shortcuts can still fire while a sheet is open. Pre-existing and out of scope here, but consider extracting one shared constant so the two lists can't diverge independently again.
Reviewed with GLM 5.3 via pi.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, self-contained UI bug fix that updates the chat keyboard guard to recognize active dialog, sheet, and mobile-sidebar overlays. Its runtime impact is limited to preventing unintended composer focus while those overlays are open or closing. You can add or adjust custom eligibility rules. Learn more. |
|
@codex re-review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

Problem
The chat type-to-focus guard checks for
[data-slot="dialog"], but the app's dialog primitives render popup slots such asdialog-popupandalert-dialog-popup. A printable key can therefore be redirected into the composer behind an open dialog.Fix
Match the actual dialog, alert-dialog, command-dialog, and sheet popup slots, including the mobile sidebar's overridden sheet slot. The selectors cover Base UI's open and ending-style states, preserving the guard through exit transitions without matching fully closed keep-mounted popups.
No visual styling changes.
Verification
vp test run apps/web/src/components/RightPanelTabs.test.tsx apps/web/src/components/ChatView.logic.test.ts(65 passed)pnpm typecheckinapps/webvp lint apps/web/src/components/ChatView.tsxreact-doctor --verbose --scope changed --base upstream/main(no issues)Built with GPT-5.6 Sol via pi.
Note
Low Risk
Narrow, chat keyboard-guard change with no auth or data impact; risk is mainly if something still relied on the old generic
dialogslot match.Overview
Fixes a bug where printable keys could still focus the chat composer while a modal was open, because the guard looked for
[data-slot="dialog"]instead of the real popup elements.TYPE_TO_FOCUS_FLOATING_LAYER_SELECTORinChatView.tsxnow targets open floating layers:dialog-popup,alert-dialog-popup,command-dialog-popup,sheet-popup, and the mobile sidebar sheet. Selectors require Base UIdata-openordata-ending-styleso keep-mounted closed sheets do not block type-to-focus. Existing menu, select, popover, combobox, and autocomplete popup selectors are unchanged.Reviewed by Cursor Bugbot for commit 7c7ed48. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Block type-to-focus behind open dialogs in
ChatViewChatView.TYPE_TO_FOCUS_FLOATING_LAYER_SELECTORin ChatView.tsx with selectors foralert-dialog,command-dialog,dialog,sheet, and the mobile sidebar.openorendingstate, replacing the generic dialog slot selector.Macroscope summarized 7c7ed48.