Skip to content

refactor(ModalAnnounceProvider): watch presentation through the shared MutationObserver - #9151

Merged
cixzhang merged 2 commits into
mainfrom
fix/modal-announce-shared-observer
Nov 1, 2026
Merged

cixzhang merged 2 commits into
mainfrom
fix/modal-announce-shared-observer

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Maintainer impact

ModalAnnounceProvider creates its own MutationObserver for each open modal to follow open, inert and aria-hidden. Core already has sharedMutationObserver.observeMutations, which keeps one observer per set of options for every registration. Two owners of the same concern drift apart: the shared one gets fixes, and the copy doesn't. Users see no change.

Intended invariant

Announcements inside open modals route exactly as before (spec:AST-086 FR14). The presentation watch starts at the open intent, follows the exit, and ends at the real close or unmount (architecture:react-component-runtime INV5).

Change

Evidence

  • Failure before the change: two open modals created two presentation observers. The new test expected one and received two on main.
  • Success after the change: the same two dialogs register with one observer. The existing INV5 test (no observer for a dialog closed at rest; observe from the open intent until the real close) passes unchanged.
  • Product/runtime behavior verified unchanged: the useAnnounce modal suite (40) and the hooks, Dialog, BottomSheet, Drawer and Lightbox suites (1,332 tests) pass.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split. The audit's note that a replaced dialog node isn't followed stays out of this PR; this one only moves the watch onto the shared owner.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm vitest run packages/core/src/hooks packages/core/src/Dialog packages/core/src/BottomSheet packages/core/src/Drawer packages/core/src/Lightbox; strict eslint and tsc clean.

…d MutationObserver

The provider's open/inert/aria-hidden watch now registers through
observeMutations, Core's one observer per set of options, instead of a
raw MutationObserver per open modal. The session still starts at the open
intent and ends at the real close or unmount (runtime INV5 test unchanged).

Test: two open modals register both dialogs with one observer.

Co-authored-by: imdreamrunner <imdreamrunner@users.noreply.github.com>
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 1, 2026 3:44pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 1, 2026, 3:51 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c04e7bf

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to merge: moving the modal presentation watch onto Core's shared observeMutations keeps announcement routing inside modals unchanged, and the new test fails on main and passes here. No changes are needed. CI skipped its lint, typecheck and test jobs on this draft head.

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 1, 2026 15:34

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to merge: moving the modal presentation watch onto Core's shared observeMutations leaves announcement routing inside modals unchanged, and the new test fails without the change and passes with it. No changes are needed; the lint, typecheck and test jobs were cancelled on this head, so they still need a green run before merging.

[Automated review]

@cixzhang
cixzhang merged commit f5db725 into main Nov 1, 2026
59 of 95 checks passed
@github-actions
github-actions Bot deleted the fix/modal-announce-shared-observer branch November 2, 2026 06:04

This branch was successfully deployed

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

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant