Skip to content

Conversation

@ebbbang
Copy link
Contributor

@ebbbang ebbbang commented Dec 12, 2025

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

  • Added dismissible prop to ModalContext interface
  • Updated Modal component to pass dismissible through context
  • Modified ModalHeader to conditionally render the close button based on dismissible prop
  • Added 2 new tests to verify the close button visibility behavior
  • Updated existing test to pass dismissible prop where needed

Behavior

  • Before: Close button always visible in modal header
  • After: Close button only visible when dismissible={true}

Test Plan

  • All existing tests pass (11/11 Modal tests)
  • Added test: close button should not render when modal is not dismissible
  • Added test: close button should render when modal is dismissible
  • Manually verified: modal without dismissible prop shows no close button
  • Manually verified: modal with dismissible={true} shows close button

Screenshots

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

  • New Features

    • Modal now supports a dismissible option so the close button is shown or hidden based on configuration.
  • Tests

    • Added tests to verify the close button is present only when the modal is dismissible and that dismissal via the button behaves correctly.
  • Chores

    • Added a changelog entry noting the close-button behavior update.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2025

🦋 Changeset detected

Latest commit: e8d03b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
flowbite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 12, 2025

@ebbbang is attempting to deploy a commit to the Themesberg Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

Adds an optional dismissible flag to ModalContext, threads the prop from Modal into the context, and uses it in ModalHeader to conditionally render the close button. Tests added/updated to verify close-button visibility based on dismissible.

Changes

Cohort / File(s) Summary
Modal context & provider
packages/ui/src/components/Modal/ModalContext.tsx, packages/ui/src/components/Modal/Modal.tsx
Adds optional dismissible?: boolean to ModalContextValue; Modal now includes dismissible in the ModalContext.Provider value.
Header rendering
packages/ui/src/components/Modal/ModalHeader.tsx
ModalHeader now renders the Close button only when dismissible from context is true (conditional rendering).
Tests & changelog
packages/ui/src/components/Modal/Modal.test.tsx, .changeset/social-kings-cut.md
Adds tests verifying close-button presence/absence based on dismissible; updates an existing test to pass dismissible; adds a changeset noting the behavior change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review focus areas:
    • ModalContextValue interface change for type correctness and exported types.
    • Provider value in Modal.tsx to ensure no accidental prop omission.
    • Conditional rendering and event handling in ModalHeader.tsx.
    • Test coverage in Modal.test.tsx for both dismissible/non-dismissible cases.

Poem

🐰 I nudged a flag into the flow,
A tiny hop, and now you know,
Close buttons bloom when allowed to flee,
Quiet when locked — soft as tea. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: hiding the modal close button when the modal is not dismissible, which aligns with the changeset modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b49ab1a and e8d03b0.

📒 Files selected for processing (1)
  • .changeset/social-kings-cut.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/social-kings-cut.md
⏰ 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

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 the false default.

With dismissible defaulting to false, 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 dismissible prop 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

📥 Commits

Reviewing files that changed from the base of the PR and between 850fbd2 and b49ab1a.

📒 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 dismissible property to the context interface is straightforward and follows the existing pattern (similar to the popup property).

packages/ui/src/components/Modal/ModalHeader.tsx (2)

34-34: LGTM! Correct context consumption.

Properly extracts the dismissible flag 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 dismissible is not set (defaults to false). Using queryByLabelText is the right choice since it returns null when 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 dismissible prop is now properly passed through the context provider, making it available to ModalHeader for conditional rendering of the close button. This creates consistent behavior where dismissible controls both outside-click dismissal (line 104) and close button visibility.

Copy link
Collaborator

@SutuSebastian SutuSebastian left a comment

Choose a reason for hiding this comment

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

LGTM!

One thing left:

  • run bun run changeset
  • select flowbite-react package
  • bump as patch

@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
flowbite-react Ready Ready Preview, Comment Dec 15, 2025 10:41am
flowbite-react-storybook Ready Ready Preview, Comment Dec 15, 2025 10:41am

@ebbbang
Copy link
Contributor Author

ebbbang commented Dec 15, 2025

LGTM!

One thing left:

  • run bun run changeset
  • select flowbite-react package
  • bump as patch

Done

@SutuSebastian SutuSebastian merged commit 5007ee9 into themesberg:main Dec 15, 2025
8 checks passed
@github-actions github-actions bot mentioned this pull request Dec 15, 2025
@ebbbang ebbbang deleted the fix/modal-close-button-dismissible branch December 15, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants