-
-
Notifications
You must be signed in to change notification settings - Fork 476
fix: hide modal close button when not dismissible #1641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: hide modal close button when not dismissible #1641
Conversation
The close button in the modal header now only renders when the modal is dismissible. This prevents confusion where users see a close button but the modal cannot be dismissed by clicking outside or pressing Escape. Changes: - Add dismissible prop to ModalContext - Conditionally render close button in ModalHeader based on dismissible - Add tests to verify close button visibility behavior
|
|
@ebbbang is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe changes add a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/ui/src/components/Modal/Modal.tsx (1)
85-85: Consider the breaking change implications of thefalsedefault.With
dismissibledefaulting tofalse, existing code that doesn't explicitly pass this prop will no longer show the close button (previously it always showed). While this fixes the inconsistency described in the PR and creates more logical behavior, it could surprise users upgrading the library.Consider:
- Adding a migration note in the changelog
- Documenting the
dismissibleprop clearly in component documentation- Potentially adding a console warning in development mode if the prop is undefined (though this might be too noisy)
Would you like me to help draft migration guidance or documentation for this change?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/ui/src/components/Modal/Modal.test.tsx(2 hunks)packages/ui/src/components/Modal/Modal.tsx(1 hunks)packages/ui/src/components/Modal/ModalContext.tsx(1 hunks)packages/ui/src/components/Modal/ModalHeader.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/ui/src/components/Modal/ModalHeader.tsx (1)
apps/web/examples/modal/modal.dismissible.tsx (1)
dismissible(78-88)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: 🧰 Build
🔇 Additional comments (7)
packages/ui/src/components/Modal/ModalContext.tsx (1)
9-9: LGTM! Clean context extension.The addition of the optional
dismissibleproperty to the context interface is straightforward and follows the existing pattern (similar to thepopupproperty).packages/ui/src/components/Modal/ModalHeader.tsx (2)
34-34: LGTM! Correct context consumption.Properly extracts the
dismissibleflag from the modal context for use in conditional rendering.
68-72: LGTM! Correct conditional rendering.The close button now only renders when the modal is dismissible, which ensures consistent behavior—non-dismissible modals won't show a close button that wouldn't work anyway. The existing
aria-label="Close"maintains accessibility when the button is rendered.packages/ui/src/components/Modal/Modal.test.tsx (3)
29-41: LGTM! Good test coverage for non-dismissible case.This test correctly verifies that the close button is not rendered when
dismissibleis not set (defaults tofalse). UsingqueryByLabelTextis the right choice since it returnsnullwhen the element is not found.
43-55: LGTM! Good test coverage for dismissible case.This test correctly verifies that the close button is rendered when
dismissible={true}is explicitly set.
113-113: LGTM! Correct test update.This test needs
dismissible={true}to ensure the close button is rendered so it can be clicked. Good catch updating this existing test.packages/ui/src/components/Modal/Modal.tsx (1)
120-120: LGTM! Correctly threads prop through context.The
dismissibleprop is now properly passed through the context provider, making it available toModalHeaderfor conditional rendering of the close button. This creates consistent behavior wheredismissiblecontrols both outside-click dismissal (line 104) and close button visibility.
Summary
Fixes the modal close button to only render when the modal is dismissible. Previously, the X button in the modal header would always display, even when
dismissible={false}, which created a confusing UX where the button appeared but had no effect.Changes
dismissibleprop toModalContextinterfaceModalcomponent to passdismissiblethrough contextModalHeaderto conditionally render the close button based ondismissiblepropdismissibleprop where neededBehavior
dismissible={true}Test Plan
dismissibleprop shows no close buttondismissible={true}shows close buttonScreenshots
N/A - behavioral change only
These follow the project's conventions from the contributing guide, including the commitizen-style prefix and the Claude Code attribution footer.
Summary by CodeRabbit
Release Notes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.