Bug: hydrated <dialog> never fires onToggle / onBeforeToggle
React version: 19.2.8, also reproduces on current main
Steps To Reproduce
const tree = <dialog ref={ref} onToggle={onToggle} onBeforeToggle={onBeforeToggle} />;
container.innerHTML = ReactDOMServer.renderToString(tree);
ReactDOMClient.hydrateRoot(container, tree);
// later:
ref.current.showModal(); // or dispatchEvent(new Event('toggle'))
The current behavior
Neither onToggle nor onBeforeToggle is ever called. In a client-rendered app (createRoot) both fire. onCancel and onClose work in both modes.
The expected behavior
The hydrated dialog behaves like the client-rendered one.
Cause
toggle and beforetoggle are in nonDelegatedEvents, so React only receives them via a per-element listenToNonDelegatedEvent call. #32479 added those calls for dialog to setInitialProperties only:
case 'dialog': {
listenToNonDelegatedEvent('beforetoggle', domElement);
listenToNonDelegatedEvent('toggle', domElement);
listenToNonDelegatedEvent('cancel', domElement);
listenToNonDelegatedEvent('close', domElement);
hydrateProperties in the same file still registers only two:
case 'dialog':
listenToNonDelegatedEvent('cancel', domElement);
listenToNonDelegatedEvent('close', domElement);
Other tags keep the two paths in sync — details registers toggle in both, and the popover attribute registers beforetoggle + toggle in both. The tests added by #32479 only use createRoot, which is why this wasn't caught.
Hi, can you assign this issue to me?
@Iyamokuma a fix is already up for this one — #37262, opened alongside the report. Sorry! If you're looking for something to pick up, #37177 has a diagnosed gap in the set-state-in-effect rule that nobody has taken yet.
I just commented, can you assign it to me?
On Mon, 10 Aug 2026 at 10:05, Sidi Eyel @.***> wrote:
SidiEyel left a comment (react/react#37261) https://github.com/react/react/issues/37261#issuecomment-5243439595
@Iyamokuma https://github.com/Iyamokuma a fix is already up for this one — #37262 https://github.com/react/react/pull/37262, opened alongside the report. Sorry! If you're looking for something to pick up, #37177 https://github.com/react/react/issues/37177 has a diagnosed gap in the set-state-in-effect rule that nobody has taken yet.
— Reply to this email directly, view it on GitHub https://github.com/react/react/issues/37261?email_source=notifications&email_token=A2RGOD5JVOZGYOPU5MO7QMT5JH6F5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMRUGM2DGOJVHE22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5243439595, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2RGODYXE6BVTMSPKSGWHS35JH6F5AVCNFSNUABEKJSXA33TNF2G64TZHMYTAMRXGAZDKMB3JFZXG5LFHM2TCMJSGM2TENRYGSQXMAQ . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/A2RGOD6CG4AO4S6F26DW2235JH6F5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMRUGM2DGOJVHE22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/A2RGOD3VXI4NP2SDQ56G4HT5JH6F5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMRUGM2DGOJVHE22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you were mentioned.Message ID: @.***>
Proposed Plan to Fix Hydrated <dialog> Toggle Events
setInitialProperties in ReactDOMComponent.js registers beforetoggle and toggle non-delegated event listeners on <dialog> elements, but hydrateProperties only registers cancel and close. As a result, hydrated <dialog> components never receive onToggle or onBeforeToggle callbacks.
Fix:
Add listenToNonDelegatedEvent('beforetoggle', domElement) and listenToNonDelegatedEvent('toggle', domElement) under case 'dialog': inside hydrateProperties to keep hydration and client-render property initialization in sync.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!