feat: Add option to close modal on mobile via overlay - #4031
Conversation
…l on overlay click
📝 WalkthroughWalkthroughAdds an ChangesMobile Overlay Close Feature
Estimated code review effort: 2 (Simple) | ~12 minutes 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cypress/component/Modal.spec.tsx (1)
175-184: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant duplicate mount.
The outer
beforeEach(line 177) mounts<WithMobileOverlayCloseEnabled />, and the innerbeforeEach(line 184) mounts it again before every test in the nested context. Only the inner mount is needed since it's the one immediately preceding the test actions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cypress/component/Modal.spec.tsx` around lines 175 - 184, The nested test setup in Modal.spec.tsx mounts WithMobileOverlayCloseEnabled twice, once in the outer beforeEach and again in the inner beforeEach, which is redundant. Remove the outer mount and keep the mount inside the nested context so the WithMobileOverlayCloseEnabled fixture is only initialized where the mobile overlay click test runs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cypress/component/Modal.spec.tsx`:
- Around line 175-194: The WithMobileOverlayCloseEnabled test is asserting the
modal is closed without ever opening it first, so it never exercises the
overlay-close behavior. Update the setup in this context to open the dialog via
the modal trigger before the mobile overlay tap, using the
WithMobileOverlayCloseEnabled example and its Modal.Target/“Open License”
interaction, then keep the existing not.exist assertion to verify
enableMobileCloseOnOverlayClick actually closes an opened modal.
---
Nitpick comments:
In `@cypress/component/Modal.spec.tsx`:
- Around line 175-184: The nested test setup in Modal.spec.tsx mounts
WithMobileOverlayCloseEnabled twice, once in the outer beforeEach and again in
the inner beforeEach, which is redundant. Remove the outer mount and keep the
mount inside the nested context so the WithMobileOverlayCloseEnabled fixture is
only initialized where the mobile overlay click test runs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9692abbe-529e-4ec9-93dc-875c751ac542
📒 Files selected for processing (4)
cypress/component/Modal.spec.tsxmodules/react/modal/lib/hooks/useCloseOnOverlayClick.tsmodules/react/modal/stories/examples/WithMobileOverlayCloseEnabled.tsxmodules/react/popup/lib/hooks/usePopupModel.ts
Workday/canvas-kit
|
||||||||||||||||||||||||||||||||||||||||
| Project |
Workday/canvas-kit
|
| Branch Review |
feature/mobile-opt-in-overlay-close
|
| Run status |
|
| Run duration | 02m 29s |
| Commit |
|
| Committer | GFKuks |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
1
|
|
|
86
|
|
|
0
|
|
|
864
|
| View all changes introduced in this branch ↗︎ | |
UI Coverage
19.6%
|
|
|---|---|
|
|
1536
|
|
|
372
|
Accessibility
99.33%
|
|
|---|---|
|
|
6 critical
5 serious
0 moderate
2 minor
|
|
|
78
|
This PR introduces an optional configuration option for modal that allows users to close modal by clicking on background overlay. By default, this behaviour is disabled for
modality === 'touch'Summary
Resolves issue #3108
For Mobile Inventory Modernization project - but also seemingly other use cases - there are cases when we have informational modals that do not critically require an explicit user selection via buttons, so dismissing modal via overlay click makes sense from a UX point of view.
Release Category
Components
Checklist
ready for reviewhas been added to PRReviewers
@josh-bagwell
@RayRedGoose
Where Should the Reviewer Start?
modules/react/modal/lib/hooks/useCloseOnOverlayClick.ts
Areas for Feedback? (optional)
Testing Manually
Screenshots or GIFs (if applicable)
Thank You Gif (optional)
Summary by CodeRabbit