fix(ui): clamped table column widths (#26991)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Dev Randalpura
2026-05-13 14:43:49 -04:00
committed by GitHub
parent fd01cc03bf
commit 71a2c0264e
2 changed files with 21 additions and 1 deletions
@@ -265,6 +265,24 @@ describe('TableRenderer', () => {
unmount();
});
it('handles extremely small terminal widths without crashing', async () => {
const headers = ['Col 1', 'Col 2'];
const rows = [['Data 1', 'Data 2']];
// This width is much smaller than the overhead, which could lead to negative column widths
const terminalWidth = 1;
const renderResult = await renderWithProviders(
<TableRenderer
headers={headers}
rows={rows}
terminalWidth={terminalWidth}
/>,
);
const { unmount } = renderResult;
// If it didn't throw RangeError: Invalid count value, the test passes
unmount();
});
it.each([
{
name: 'handles non-ASCII characters (emojis and Asian scripts) correctly',
+3 -1
View File
@@ -250,7 +250,9 @@ export const TableRenderer: React.FC<TableRendererProps> = ({
};
const char = chars[type];
const borderParts = adjustedWidths.map((w) => char.horizontal.repeat(w));
const borderParts = adjustedWidths.map((w) =>
char.horizontal.repeat(Math.max(0, w || 0)),
);
const border = char.left + borderParts.join(char.middle) + char.right;
return <Text color={theme.border.default}>{border}</Text>;