fix(Dialog): scope overlay pointerdown prevention to the overlay itself#2668
Conversation
#2655 added `@pointerdown.left.prevent` on the overlay so focus stays on the trigger after the dialog closes. When `DialogContent` is nested inside `DialogOverlay` (a common centering pattern), that handler also fired for pointerdown events bubbling up from controls inside the content, calling `preventDefault()` on them. That suppressed native behavior — `<select>` dropdowns wouldn't open and `<input>`/`<textarea>` wouldn't focus on click. Add the `.self` modifier so the prevention only applies when the pointer lands directly on the overlay backdrop, preserving the #2655 behavior while leaving descendant interactions untouched. Fixes #2660 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR fixes pointer event handling in Dialog's overlay component. The overlay handler is narrowed to prevent pointerdown only on the overlay itself using the ChangesDialog overlay pointer event specificity
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
commit: |
Summary
Fixes #2660 — a regression introduced in 2.9.8 where native
<select>dropdowns won't open and<input>/<textarea>won't focus when clicked inside a<Dialog>.Root cause
#2655 (
fix(Dialog): restore focus to trigger after overlay click) added@pointerdown.left.preventtoDialogOverlayImplso that clicking the overlay backdrop keeps focus on the trigger after the dialog closes (by skipping the browser's compatibilitymousedown).When
DialogContentis nested insideDialogOverlay— a very common centering pattern, and what the reporter's reproduction uses —pointerdownevents bubble up from controls inside the content to the overlay. The overlay's listener then calledpreventDefault()on them too, which suppresses native behaviors:<select>dropdowns don't open<input>/<textarea>don't focus on clickFix
Add the
.selfmodifier:@pointerdown.left.self.prevent. The prevention now only applies when the pointer lands directly on the overlay backdrop (event.target === overlay), not on descendants. This preserves the #2655 behavior while leaving in-content interactions untouched.Tests
Added a regression block in
Dialog.test.tsusing a dialog whose content is nested inside the overlay (reproducing the exact structure):pointerdownon a control inside the content is notdefaultPreventedVerified these tests fail on the old
@pointerdown.left.preventand pass with the.selffix. The existing overlay-click tests from #2655 still pass (they dispatch on the overlay directly). Fullreka-uisuite is green.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests