Skip to content

feat: add modal close completion callback - #1148

Merged
gnapse merged 2 commits into
mainfrom
ernesto/feat-modal-close-complete
Aug 4, 2026
Merged

feat: add modal close completion callback#1148
gnapse merged 2 commits into
mainfrom
ernesto/feat-modal-close-complete

Conversation

@gnapse

@gnapse gnapse commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Short description

Adds onCloseComplete to Modal. The callback runs once after a committed open-to-closed transition, when the modal and its focus lock have unmounted.

PR Checklist

  • Added tests for bugs / new features
  • Updated docs (storybooks, readme)
  • Reviewed and approved Chromatic visual regression tests in CI

@gnapse gnapse self-assigned this Aug 4, 2026
@gnapse
gnapse requested a review from doistbot August 4, 2026 15:16

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Adds onCloseComplete to Modal — a callback that fires once after a committed open-to-closed transition, when the modal and its focus lock have unmounted.

Few things worth tightening:

  • Consider switching from useLayoutEffect to useEffect: since this invokes consumer-provided code synchronously before paint, any nontrivial handler delays the visible close. A passive effect still guarantees the DOM removal has committed, which is all that's required.
  • In the test, add an assertion that the dialog is present after the opening rerender before checking it's gone. Without verifying the modal actually mounted, the unmount assertions can pass vacuously.

Share FeedbackReview Logs

Comment thread src/modal/modal.tsx Outdated
Comment thread src/modal/modal.test.tsx
@gnapse
gnapse requested review from a team and rfgamaral and removed request for a team August 4, 2026 15:30
@gnapse
gnapse merged commit d1c02c1 into main Aug 4, 2026
13 checks passed
@gnapse
gnapse deleted the ernesto/feat-modal-close-complete branch August 4, 2026 15:30
doist-release-bot Bot pushed a commit that referenced this pull request Aug 4, 2026
## [36.1.0](v36.0.0...v36.1.0) (2026-08-04)

### Features

* add modal close completion callback ([#1148](#1148)) ([d1c02c1](d1c02c1))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 36.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@doist-release-bot doist-release-bot Bot added the Released PRs that have been merged and released label Aug 4, 2026

@rfgamaral rfgamaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs that have been merged and released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants