diff --git a/packages/cli/src/ui/components/shared/VirtualizedList.test.tsx b/packages/cli/src/ui/components/shared/VirtualizedList.test.tsx
index af1ec8df589..ecfc19359ee 100644
--- a/packages/cli/src/ui/components/shared/VirtualizedList.test.tsx
+++ b/packages/cli/src/ui/components/shared/VirtualizedList.test.tsx
@@ -92,6 +92,82 @@ describe('', () => {
expect(listRef!.getScrollIndex()).toBe(19);
});
+ it('collapses bottom-stuck viewport to measured rows when estimates are too tall', async () => {
+ const tallEstimate = () => 4;
+
+ const { lastFrame, rerender } = render(
+
+ data={makeItems(20)}
+ renderItem={renderItem}
+ estimatedItemHeight={tallEstimate}
+ keyExtractor={keyExtractor}
+ initialScrollIndex={SCROLL_TO_ITEM_END}
+ containerHeight={20}
+ width={40}
+ showScrollbar={false}
+ />,
+ );
+
+ for (let i = 0; i < 2; i++) {
+ rerender(
+
+ data={makeItems(20)}
+ renderItem={renderItem}
+ estimatedItemHeight={tallEstimate}
+ keyExtractor={keyExtractor}
+ initialScrollIndex={SCROLL_TO_ITEM_END}
+ containerHeight={20}
+ width={40}
+ showScrollbar={false}
+ />,
+ );
+ await act(async () => {});
+ }
+
+ const frame = lastFrame() ?? '';
+ expect(frame).toContain('item-0');
+ expect(frame).toContain('item-19');
+ expect(frame.endsWith('item-19')).toBe(true);
+ });
+
+ it('collapses a short bottom-stuck list below the container height', async () => {
+ const { lastFrame, rerender } = render(
+
+ data={makeItems(5)}
+ renderItem={renderItem}
+ estimatedItemHeight={estimatedItemHeight}
+ keyExtractor={keyExtractor}
+ initialScrollIndex={SCROLL_TO_ITEM_END}
+ containerHeight={20}
+ width={40}
+ showScrollbar={false}
+ />,
+ );
+
+ rerender(
+
+ data={makeItems(5)}
+ renderItem={renderItem}
+ estimatedItemHeight={estimatedItemHeight}
+ keyExtractor={keyExtractor}
+ initialScrollIndex={SCROLL_TO_ITEM_END}
+ containerHeight={20}
+ width={40}
+ showScrollbar={false}
+ />,
+ );
+ await act(async () => {});
+
+ const frame = lastFrame() ?? '';
+ expect(frame.split('\n')).toEqual([
+ 'item-0',
+ 'item-1',
+ 'item-2',
+ 'item-3',
+ 'item-4',
+ ]);
+ });
+
it('targetScrollIndex anchors to that index on first usable render', () => {
type RefShape = VirtualizedListRef- ;
let listRef: RefShape | null = null;