File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -564,6 +564,22 @@ const preserveExpansionStates = ExecutionEnvironment.canUseDOM ? function(skipEv
564564 return setTimeout ( preserveExpansionStates , 100 ) ;
565565 }
566566
567+ // Wait for React hydration to complete on initial page load with hash
568+ // Check if React has hydrated by looking for React internal properties
569+ if ( ! skipEventListener && location . hash && ! window . __hydrationComplete ) {
570+ const rootElement = document . getElementById ( '__docusaurus' ) ;
571+ // Check if React has attached its fiber root (sign of hydration completion)
572+ const isHydrated = rootElement && ( rootElement . _reactRootContainer || rootElement . _reactRootContainer === null || Object . keys ( rootElement ) . some ( key => key . startsWith ( '__react' ) ) ) ;
573+
574+ if ( ! isHydrated ) {
575+ return setTimeout ( preserveExpansionStates , 100 ) ;
576+ }
577+
578+ // Extra safety delay after hydration detected
579+ window . __hydrationComplete = true ;
580+ return setTimeout ( preserveExpansionStates , 50 ) ;
581+ }
582+
567583 // Add copy buttons to config fields
568584 addCopyButtons ( ) ;
569585
You can’t perform that action at this time.
0 commit comments