Skip to content

[DOM] Register dialog toggle events during hydration - #37262

Open
SidiEyel wants to merge 1 commit into
react:mainfrom
SidiEyel:hydrate-dialog-toggle-events
Open

SidiEyel wants to merge 1 commit into
react:mainfrom
SidiEyel:hydrate-dialog-toggle-events

Conversation

@SidiEyel

Copy link
Copy Markdown
Contributor

Summary

Fixes #37261.

toggle and beforetoggle are in nonDelegatedEvents, so React only receives them through the per-element listenToNonDelegatedEvent call. #32479 added those calls for dialog to setInitialProperties but not to hydrateProperties, so a hydrated <dialog> never fires onToggle or onBeforeToggle while a client-rendered one does. onCancel and onClose work in both modes, and details and the popover attribute register the same events in both paths.

This adds the two missing registrations to the hydration path.

How did you test this change?

  • Added a test that hydrates a <dialog> with all four handlers and dispatches the four events. It fails on main (onBeforeToggle and onToggle receive 0 calls) and passes with this change.
  • yarn test ReactDOMEventListener ReactDOMEventPropagation (115 tests) — pass.
  • yarn test ReactDOMEventListener --prod (24 tests) — pass.
  • yarn test ReactDOMServerIntegration (1602 tests) — pass.
  • yarn test ReactDOMFizzServer (223 tests) — pass.
  • yarn prettier, yarn linc, yarn flow dom-node — clean.

toggle and beforetoggle are non-delegated events, so React only receives
them through the per-element listenToNonDelegatedEvent call. react#32479
added those calls for dialog to setInitialProperties but not to
hydrateProperties, so a hydrated dialog never fires onToggle or
onBeforeToggle while a client-rendered one does. details and the popover
attribute register the same events in both paths.

Fixes react#37261

@dianatofficial dianatofficial 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.

Good refactor. Readability is much improved.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

The build for this commit did not complete, so there is no size report. See the workflow run for details.

Generated by sizebot against 85853c3

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: hydrated <dialog> never fires onToggle / onBeforeToggle

2 participants