refactor(ui): remove truncation detection fix per feedback and finalize bubbling fix

This commit is contained in:
Coco Sheng
2026-03-11 14:28:07 -04:00
parent 2e98057701
commit 103c595975
2 changed files with 2 additions and 19 deletions
@@ -6,7 +6,7 @@
import { render, renderWithProviders } from '../../../test-utils/render.js';
import { OverflowProvider } from '../../contexts/OverflowContext.js';
import { MaxSizedBox, ceilHeight } from './MaxSizedBox.js';
import { MaxSizedBox } from './MaxSizedBox.js';
import { MarkdownDisplay } from '../../utils/MarkdownDisplay.js';
import { Box, Text } from 'ink';
import { act } from 'react';
@@ -316,17 +316,4 @@ describe('<MaxSizedBox />', () => {
expect(lastFrame()).toMatchSnapshot();
unmount();
});
describe('ceilHeight', () => {
it('should round up fractional heights to next integer', () => {
expect(ceilHeight(2.1)).toBe(3);
expect(ceilHeight(2.9)).toBe(3);
expect(ceilHeight(2.0)).toBe(2);
expect(ceilHeight(0.1)).toBe(1);
});
it('should handle zero correctly', () => {
expect(ceilHeight(0)).toBe(0);
});
});
});
@@ -28,9 +28,6 @@ export interface MaxSizedBoxProps {
additionalHiddenLinesCount?: number;
}
/** Ensures that fractional heights are correctly identified as overflowing. */
export const ceilHeight = (height: number): number => Math.ceil(height);
/**
* A React component that constrains the size of its children and provides
* content-aware truncation when the content exceeds the specified `maxHeight`.
@@ -58,8 +55,7 @@ export const MaxSizedBox: React.FC<MaxSizedBoxProps> = ({
const observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
// Use ceilHeight to ensure that fractional heights (e.g. from zooming) that exceed the limit are correctly identified as overflowing.
setContentHeight(ceilHeight(entry.contentRect.height));
setContentHeight(entry.contentRect.height);
}
});
observer.observe(node);