Skip to content

Commit 2b091ee

Browse files
committed
fix: wrap scrollToIndex in requestAnimationFrame
1 parent 1a5715e commit 2b091ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/select/parts/virtual-list.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ const VirtualListOpen = forwardRef(
7474
menuEl: menuRefObject?.current,
7575
});
7676
} else {
77-
scrollToIndex(index);
77+
// Fix for AWSUI-61506. Defer scroll to next frame to ensure
78+
// virtual items are measured after re-render. When called from
79+
// parent's useEffect, measurements may not be ready yet.
80+
requestAnimationFrame(() => scrollToIndex(index));
7881
}
7982
}
8083
previousHighlightedIndex.current = index;

0 commit comments

Comments
 (0)