@@ -56,27 +56,17 @@ export const useOverflowContainer = <TElement extends HTMLElement>(
5656
5757 const managerRef = React . useRef < OverflowManager | null > ( null ) ;
5858
59- // Whether the container's observe effect has run. Item/menu hooks request first-paint correctness
60- // via `forceUpdateOverflow`; before the container observes there is nothing to compute yet, so the
61- // request is recorded here and honored when the observe effect runs.
62- const hasObservedRef = React . useRef ( false ) ;
63- // Set when a descendant requests first-paint correctness before the container observes. The default
64- // item/menu hooks make this request; a hook that omits it opts the container out of the synchronous
65- // first-paint pass (the hot path), letting the ResizeObserver drive the first overflow pass instead.
66- const pendingForceUpdateRef = React . useRef ( false ) ;
67-
6859 if ( managerRef . current === null ) {
6960 managerRef . current = canUseDOM ( ) ? createOverflowManager ( observeOptions ) : null ;
7061 }
7162
7263 useIsomorphicLayoutEffect ( ( ) => {
7364 if ( managerRef . current && containerRef . current ) {
74- // Child item/menu effects already ran (child-before-parent), so `pendingForceUpdateRef`
75- // reflects whether any descendant requested first-paint correctness. When requested, resolve
76- // overflow synchronously so the first paint is correct; the manager guards the force on the
77- // container being measured.
78- managerRef . current . observe ( containerRef . current , { forceUpdate : pendingForceUpdateRef . current } ) ;
79- hasObservedRef . current = true ;
65+ // First-paint correctness is requested by descendants (the default item/menu hooks call
66+ // forceUpdateOverflow during their layout effects, which commit before this one). The manager
67+ // honors any such pre-observe request here, guarded on the container being measured. A consumer
68+ // whose item hook omits that request opts out — the ResizeObserver drives the first pass.
69+ managerRef . current . observe ( containerRef . current ) ;
8070 return ( ) => managerRef . current ?. disconnect ( ) ;
8171 }
8272 } , [ ] ) ;
@@ -132,14 +122,9 @@ export const useOverflowContainer = <TElement extends HTMLElement>(
132122 ) ;
133123
134124 const forceUpdateOverflow = React . useCallback ( ( ) => {
135- // Before the container observes, a force can't compute anything (it isn't observing yet), so
136- // record the request and let the observe effect honor it (first-paint correctness). After
137- // observing, force directly.
138- if ( hasObservedRef . current ) {
139- managerRef . current ?. forceUpdate ( ) ;
140- } else {
141- pendingForceUpdateRef . current = true ;
142- }
125+ // The manager handles the before/after-observe distinction: a call before observation is
126+ // recorded and applied once it observes (first-paint correctness); a call after forces directly.
127+ managerRef . current ?. forceUpdate ( ) ;
143128 } , [ ] ) ;
144129
145130 return {
0 commit comments