11// Used for UnderlineNav and UnderlinePanels components
22
3- import React from 'react'
3+ import React , { useState } from 'react'
44import { type ForwardedRef , forwardRef , type FC , type PropsWithChildren , type ElementType } from 'react'
55import { isElement } from 'react-is'
66import type { IconProps } from '@primer/octicons-react'
77import CounterLabel from '../../CounterLabel'
88import type { ForwardRefComponent as PolymorphicForwardRefComponent } from '../../utils/polymorphic'
9+ import useIsomorphicLayoutEffect from '../../utils/useIsomorphicLayoutEffect'
910
1011import classes from './UnderlineTabbedInterface.module.css'
1112import { clsx } from 'clsx'
@@ -22,10 +23,19 @@ type UnderlineWrapperProps<As extends React.ElementType> = {
2223
2324export const UnderlineWrapper = forwardRef ( ( props , ref ) => {
2425 const { children, className, as : Component = 'div' , ...rest } = props
26+ // Track hydration state: true on server and initial client render, false after hydration
27+ const [ isSSR , setIsSSR ] = useState ( true )
28+
29+ useIsomorphicLayoutEffect ( ( ) => {
30+ // After hydration, allow overflow to be visible
31+ setIsSSR ( false )
32+ } , [ ] )
33+
2534 return (
2635 < Component
2736 className = { clsx ( classes . UnderlineWrapper , className ) }
2837 ref = { ref as ForwardedRef < HTMLDivElement > }
38+ data-ssr-hidden = { isSSR ? 'true' : 'false' }
2939 { ...rest }
3040 >
3141 { children }
0 commit comments