Skip to content

Commit 7cc19c2

Browse files
fix(cli): prevent settings dialog border clipping using maxHeight (#26507)
1 parent 1d72a12 commit 7cc19c2

4 files changed

Lines changed: 112 additions & 1 deletion

packages/cli/src/ui/components/SettingsDialog.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,36 @@ describe('SettingsDialog', () => {
326326
});
327327
unmount();
328328
});
329+
330+
it('should render the bottom border correctly when height is constrained', async () => {
331+
const settings = createMockSettings();
332+
const onSelect = vi.fn();
333+
const constrainedHeight = 15;
334+
335+
const renderResult = await renderDialog(settings, onSelect, {
336+
availableTerminalHeight: constrainedHeight,
337+
});
338+
339+
await renderResult.waitUntilReady();
340+
341+
await waitFor(() => {
342+
const output = renderResult.lastFrame();
343+
const lines = output.trim().split('\n');
344+
345+
// Verify height constraint
346+
expect(lines.length).toBeLessThanOrEqual(constrainedHeight);
347+
348+
// Verify bottom border existence in the last line of the output
349+
const lastLine = lines[lines.length - 1];
350+
// 'round' border characters: ─, ╰, ╯
351+
expect(lastLine).toMatch(/[]/);
352+
});
353+
354+
// SVG snapshot ensures visual layout and border rendering are preserved
355+
await expect(renderResult).toMatchSvgSnapshot();
356+
357+
renderResult.unmount();
358+
});
329359
});
330360

331361
describe('Setting Descriptions', () => {
Lines changed: 63 additions & 0 deletions
Loading

packages/cli/src/ui/components/__snapshots__/SettingsDialog.test.tsx.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ exports[`SettingsDialog > Initial Rendering > should render settings list with v
4646
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
4747
`;
4848

49+
exports[`SettingsDialog > Initial Rendering > should render the bottom border correctly when height is constrained 1`] = `
50+
"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
51+
│ │
52+
│ > Settings │
53+
│ │
54+
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │
55+
│ ╰─Search to filter─────────────────────────────────────────────────────────────────────────────╯ │
56+
│ ▲ │
57+
│ ● Vim Mode false │
58+
│ ▼ Enable Vim keybindings │
59+
│ │
60+
│ Apply To │
61+
│ ● User Settings │
62+
│ (Use Enter to select, Ctrl+L to reset, Tab to change focus, Esc to close) │
63+
│ │
64+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"
65+
`;
66+
4967
exports[`SettingsDialog > Snapshot Tests > should render 'accessibility settings enabled' correctly 1`] = `
5068
"╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
5169
│ │

packages/cli/src/ui/components/shared/BaseSettingsDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ export function BaseSettingsDialog({
425425
flexDirection="row"
426426
padding={1}
427427
width="100%"
428-
height="100%"
428+
maxHeight={availableHeight}
429429
>
430430
<Box flexDirection="column" flexGrow={1}>
431431
{/* Title */}

0 commit comments

Comments
 (0)