Skip to content

fix(react): keep overlay ref when dismiss is refused - #31773

Open
vurumalla92 wants to merge 1 commit into
ionic-team:mainfrom
vurumalla92:fix/react-useoverlay-dismiss-28964
Open

vurumalla92 wants to merge 1 commit into
ionic-team:mainfrom
vurumalla92:fix/react-useoverlay-dismiss-28964

Conversation

@vurumalla92

Copy link
Copy Markdown

Fixes #28964

Problem

useOverlay cleared overlayRef/containerElRef unconditionally after awaiting overlay.dismiss(). When canDismiss returned false, the modal stayed open but the ref was gone, so the next dismiss() call was a no-op and the modal could no longer be dismissed at all.

Fix

Only clear the refs when dismiss() resolves to true, exactly as proposed in #28964. If dismissal is refused, the ref is kept so the user can dismiss again later.

Tests

Verified with a standalone React 19 + happy-dom harness rendering the real packages/react/src/hooks/useOverlay.ts with a fake overlay controller whose dismiss() first refuses (like canDismiss returning false) and then allows:

  • 5/5 checks pass with this fix (refused dismiss reaches the overlay twice, allowed dismiss succeeds, a fresh overlay can be presented afterwards).
  • Negative control: the original file fails exactly the 2 bug checks (second refused dismiss and allowed dismiss never reach the overlay).

Caveat: this was verified with the standalone harness above, not with the repo's full test suite.

useOverlay cleared overlayRef/containerElRef unconditionally after
awaiting overlay.dismiss(), so when canDismiss returned false the
modal could no longer be dismissed: the next dismiss() call was a
no-op because the ref was gone. Only clear the refs when dismiss()
resolves to true, as proposed in ionic-team#28964.

Fixes ionic-team#28964
@vurumalla92
vurumalla92 requested a review from a team as a code owner November 18, 2026 14:39
@vurumalla92
vurumalla92 requested a review from thetaPC November 18, 2026 14:39
@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@vurumalla92 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: react @ionic/react package label Nov 18, 2026
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 18, 2026 3:28pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 2b7db1de Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: react @ionic/react package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: dismiss callback from useIonModal is not called after first dismiss

1 participant