[LG-5601] fix(modal): restore conditional rendering of children when closed#3189
Merged
[LG-5601] fix(modal): restore conditional rendering of children when closed#3189
Conversation
🦋 Changeset detectedLatest commit: 98ad0f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Restores conditional rendering of Modal children so they unmount when the Modal is closed (regression fix from v20, returning to v19 behavior). This reduces unnecessary DOM nodes and lifecycle work while keeping the underlying dialog element mounted for API correctness.
- Wraps modal content (children, CloseButton, portal container) in an open guard
- Updates test to assert children are not rendered when closed
- Adds a changeset documenting the patch release
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/modal/src/Modal/ModalView.tsx | Wraps all modal children in a conditional block keyed to open, ensuring they unmount when closed. |
| packages/modal/src/Modal/Modal.spec.tsx | Updates test to verify dialog remains but children are not rendered when closed. |
| .changeset/two-dogs-smash.md | Adds patch changeset describing the regression fix. |
TheSonOfThomp
approved these changes
Oct 7, 2025
Contributor
|
Size Change: +27 B (0%) Total Size: 1.59 MB
ℹ️ View Unchanged
|
kraenhansen
approved these changes
Oct 7, 2025
810c67d to
98ad0f9
Compare
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✍️ Proposed changes
Fixes a regression introduced in Modal v20 where children remained mounted in the DOM even when the modal was closed. This change restores the v19 behavior where Modal children are conditionally rendered based on the
openprop.The fix ensures:
<dialog>element remains in the DOM (required forshowModal()andclose()methods to work correctly)openistrue🎟️ Jira ticket: LG-5601
✅ Checklist
pnpm changesetand documented my changes🧪 How to test changes
pnpm -w test packages/modalto verify Modal tests passpnpm -w test packages/confirmation-modalto verify ConfirmationModal tests passpnpm -w test packages/marketing-modalto verify MarketingModal tests pass