@@ -184,7 +184,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
184
184
// adjusted space. In very specific cases this might result in the scrollbars disappearing
185
185
// again, resulting in extra padding. We stop after a maximum of two layout passes to avoid
186
186
// an infinite loop. This matches how browsers behavior with native CSS grid layout.
187
- if ( ! isTestEnv && clientWidth !== dom . clientWidth || clientHeight !== dom . clientHeight ) {
187
+ if ( ! isTestEnv && ( dom . checkVisibility ?. ( ) ?? true ) && ( clientWidth !== dom . clientWidth || clientHeight !== dom . clientHeight ) ) {
188
188
state . width = dom . clientWidth ;
189
189
state . height = dom . clientHeight ;
190
190
flush ( ( ) => {
@@ -198,7 +198,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
198
198
199
199
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
200
200
let lastContentSize = useRef < Size | null > ( null ) ;
201
- let [ update , setUpdate ] = useState ( { } ) ;
201
+ let [ update , setUpdate ] = useState < { } | false > ( false ) ;
202
202
useLayoutEffect ( ( ) => {
203
203
if ( ! isUpdatingSize . current && ( lastContentSize . current == null || ! contentSize . equals ( lastContentSize . current ) ) ) {
204
204
// React doesn't allow flushSync inside effects, so queue a microtask.
@@ -224,7 +224,9 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
224
224
225
225
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
226
226
useLayoutEffect ( ( ) => {
227
- updateSize ( fn => fn ( ) ) ;
227
+ if ( update ) {
228
+ updateSize ( fn => fn ( ) ) ;
229
+ }
228
230
} , [ update ] ) ;
229
231
230
232
let onResize = useCallback ( ( ) => {
0 commit comments