Skip to content

fix(web): block type-to-focus behind open dialogs - #8139

Open
Lucenx9 wants to merge 3 commits into
pingdotgg:mainfrom
Lucenx9:fix/type-to-focus-open-dialogs
Open

fix(web): block type-to-focus behind open dialogs#8139
Lucenx9 wants to merge 3 commits into
pingdotgg:mainfrom
Lucenx9:fix/type-to-focus-open-dialogs

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Problem

The chat type-to-focus guard checks for [data-slot="dialog"], but the app's dialog primitives render popup slots such as dialog-popup and alert-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 typecheck in apps/web
  • vp lint apps/web/src/components/ChatView.tsx
  • react-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 dialog slot 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_SELECTOR in ChatView.tsx now targets open floating layers: dialog-popup, alert-dialog-popup, command-dialog-popup, sheet-popup, and the mobile sidebar sheet. Selectors require Base UI data-open or data-ending-style so 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 ChatView

  • Updates ChatView.TYPE_TO_FOCUS_FLOATING_LAYER_SELECTOR in ChatView.tsx with selectors for alert-dialog, command-dialog, dialog, sheet, and the mobile sidebar.
  • Constrains all popup selectors to match only elements in an open or ending state, replacing the generic dialog slot selector.
  • Behavioral Change: Type-to-focus logic now only reacts to open or ending popups and dialogs, and includes the newly added component types.

Macroscope summarized 7c7ed48.

Copilot AI lite review requested due to automatic review settings August 24, 2026 22:04

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b450bfd3-03e6-4c55-b4e6-f7e851decdaf

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. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7763c12d-e208-489a-b062-4244e7d77ddf

📥 Commits

Reviewing files that changed from the base of the PR and between 9996038 and 38e9afe.

📒 Files selected for processing (1)
  • apps/web/src/components/ChatView.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

ChatView now detects open alert-dialog, command-dialog, dialog, and sheet popups during type-to-focus behavior.

Changes

Chat focus behavior

Layer / File(s) Summary
Open popup detection
apps/web/src/components/ChatView.tsx
The floating-layer selector now checks open popup elements by their data-slot attributes.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 38e9a

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: t3dotgg, maria-rcks, chrisdeeming

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the problem, fix, scope, and verification, although it does not use the template headings or include the checklist.
Title check ✅ Passed The title is concise and accurately describes the fix for type-to-focus behavior behind open dialogs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 24, 2026
@Lucenx9

Lucenx9 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/components/ChatView.tsx Outdated

@macroscopeapp macroscopeapp Bot 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.

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

Comment thread apps/web/src/components/ChatView.tsx Outdated

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/ChatView.tsx Outdated

@Lucenx9 Lucenx9 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the sheet-popup selector. The dedicated fifth selector is needed and correct. The desktop sidebar never renders data-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:

  • RightPanelSheet renders a keepMounted SheetPopup that 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 carry data-closed.
  • During exit transitions the popup has data-closed + data-ending-style, so the guard survives close animations. data-open is present during enter (data-starting-style is 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

  1. 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 for shouldTypeToFocusComposer asserting (a) false with an open dialog-popup in the document, and (b) true with a keep-mounted closed sheet-popup (data-closed only) would pin both the fix and the subtle state-filter contract. The PR only re-runs existing suites.

  2. LAUNCHER_SHORTCUT_BLOCKING_LAYERS (RightPanelTabs.tsx:107) now drifts further. That parallel list has no sheet-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.

@macroscopeapp

macroscopeapp Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7c7ed48

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.

@Lucenx9

Lucenx9 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@codex re-review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 7c7ed48de0

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants