Skip to content

Commit f7a1e20

Browse files
committed
fix picker tests
1 parent 15bc7d1 commit f7a1e20

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/@react-aria/virtualizer/src/ScrollView.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
198198

199199
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
200200
let lastContentSize = useRef<Size | null>(null);
201-
let [, setUpdate] = useState({});
202-
let queuedUpdateSize = useRef(false);
201+
let [update, setUpdate] = useState({});
202+
203203
useLayoutEffect(() => {
204204
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
205205
// React doesn't allow flushSync inside effects, so queue a microtask.
@@ -212,23 +212,21 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
212212
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
213213
// Queue call of updateSize to happen in a separate render but within the same act so that RAC virtualized ComboBoxes and Selects
214214
// work properly
215-
queuedUpdateSize.current = true;
216215
setUpdate({});
217216
lastContentSize.current = contentSize;
218-
return;
217+
return
219218
} else {
220219
queueMicrotask(() => updateSize(flushSync));
221220
}
222221
}
223222

224-
if (queuedUpdateSize.current) {
225-
queuedUpdateSize.current = false;
226-
updateSize(fn => fn());
227-
}
228-
229223
lastContentSize.current = contentSize;
230224
});
231225

226+
useLayoutEffect(() => {
227+
updateSize(fn => fn());
228+
}, [update])
229+
232230
let onResize = useCallback(() => {
233231
updateSize(flushSync);
234232
}, [updateSize]);

0 commit comments

Comments
 (0)