fix(cli): hide scrollbars when in alternate buffer copy mode (#18354)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Andrew Garrett
2026-02-11 07:30:27 +11:00
committed by GitHub
parent f9fc9335f5
commit ef02cec2cd
6 changed files with 67 additions and 7 deletions

View File

@@ -16,6 +16,13 @@ import {
useState,
} from 'react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import type { UIState } from '../../contexts/UIStateContext.js';
vi.mock('../../contexts/UIStateContext.js', () => ({
useUIState: vi.fn(() => ({
copyModeEnabled: false,
})),
}));
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -324,4 +331,39 @@ describe('<VirtualizedList />', () => {
expect(ref.current?.getScrollState().scrollTop).toBe(4);
});
it('renders correctly in copyModeEnabled when scrolled', async () => {
const { useUIState } = await import('../../contexts/UIStateContext.js');
vi.mocked(useUIState).mockReturnValue({
copyModeEnabled: true,
} as Partial<UIState> as UIState);
const longData = Array.from({ length: 100 }, (_, i) => `Item ${i}`);
// Use copy mode
const { lastFrame } = render(
<Box height={10} width={100}>
<VirtualizedList
data={longData}
renderItem={({ item }) => (
<Box height={1}>
<Text>{item}</Text>
</Box>
)}
keyExtractor={(item) => item}
estimatedItemHeight={() => 1}
initialScrollIndex={50}
/>
</Box>,
);
await act(async () => {
await delay(0);
});
// Item 50 should be visible
expect(lastFrame()).toContain('Item 50');
// And surrounding items
expect(lastFrame()).toContain('Item 59');
// But far away items should not be (ensures we are actually scrolled)
expect(lastFrame()).not.toContain('Item 0');
});
});