fix(modal): require pointerdown intent before backdrop dismiss#308
Conversation
|
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 (1)
📝 WalkthroughWalkthroughModal dismissal detection shifts from coordinate-based bounding-rectangle checking to event-sequence tracking. A ChangesModal Backdrop Detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
- Coverage 96.95% 93.03% -3.92%
==========================================
Files 70 166 +96
Lines 1542 2756 +1214
Branches 150 405 +255
==========================================
+ Hits 1495 2564 +1069
- Misses 28 100 +72
- Partials 19 92 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Closes #304
Closes #306
LumexModaldecided whether a click hit the backdrop by comparing the click'sclientX/Yagainst the dialog's bounding rect. That check misfires whenever aclickbubbles up from inside the dialog with coordinates reported outside the rect:LumexTextbox, drags to select text, releases over the backdrop. The browser dispatches aclickon the dialog (closest common ancestor) withclientX/Yat the mouseup position, outside the rect → modal closes mid-text-selection.<select>inside the modal. The bubbledclickarrives at the dialog withclientX/Youtside the rect (option panel coords, or synthesized(0, 0)for keyboard-initiated commit) → modal closes despite the pointer never targeting the backdrop.What's been done?
src/LumexUI/wwwroot/js/components/modal.js, replace the bounding-rect coordinate check with the standard "mousedown intent" pattern: only dismiss when both thepointerdownand theclicktarget the dialog element itself. The native<dialog>::backdropis a pseudo-element of the dialog, so a real backdrop press surfaces asevent.target === dialog; any interaction that originates inside the dialog content has a different target onpointerdownand is ignored.destroyto keep cleanup symmetric.No JS-level test infrastructure exists in the repo, so the change is not covered by automated tests. The existing
ModalTests(which mockmodal.js) still pass. Manual verification of both repros recommended.Checklist
Additional Notes
Manual repro steps to verify the fix:
LumexTextbox, click and drag inside the textbox to select text, release the mouse outside the modal. The modal should remain open.<select>(e.g.Size="@ModalSize.Large",ScrollBehavior="@ScrollBehavior.Inside"), click the select to open its picker. The modal should remain open while interacting with the picker.Summary by CodeRabbit