fix(document-graph): truncate long text lines in document nodes

Document nodes with long unbroken text (like separator lines with ====)
were bleeding outside their boundaries. Fixed by:
- Setting fixed width (280px) on container instead of just maxWidth
- Using break-all word breaking for description text
- Adding webkit line clamping to limit description to 3 lines
- Using text-overflow: ellipsis with overflow: hidden
This commit is contained in:
Pedram Amini
2026-02-01 22:59:23 -06:00
parent 9dbb2419b6
commit 13f68c15a7
2 changed files with 35 additions and 2 deletions

View File

@@ -288,6 +288,19 @@ describe('DocumentNode', () => {
const truncatedText = description.slice(0, 100).trim() + '...';
expect(screen.getByText(truncatedText)).toBeInTheDocument();
});
it('applies line clamping styles to description for overflow handling', () => {
const props = createNodeProps({ description: 'Some description text' });
renderWithProvider(<DocumentNode {...props} />);
const descriptionElement = screen.getByText('Some description text');
// Should have line clamping and word break styles
expect(descriptionElement).toHaveStyle({
overflow: 'hidden',
wordBreak: 'break-all',
});
});
});
describe('Selection State', () => {
@@ -370,6 +383,21 @@ describe('DocumentNode', () => {
});
});
describe('Container Dimensions', () => {
it('has fixed width to prevent overflow from long content', () => {
const props = createNodeProps();
const { container } = renderWithProvider(<DocumentNode {...props} />);
const nodeElement = container.querySelector('.document-node');
expect(nodeElement).toHaveStyle({
width: '280px',
maxWidth: '280px',
overflow: 'hidden',
});
});
});
describe('Theme Integration', () => {
it('uses theme background color', () => {
const props = createNodeProps();

View File

@@ -94,6 +94,7 @@ export const DocumentNode = memo(function DocumentNode({ data, selected }: Docum
padding: 12,
minWidth: 200,
maxWidth: 280,
width: 280,
overflow: 'hidden' as const,
boxShadow: isHighlighted
? `0 0 0 3px ${theme.colors.accent}40, 0 4px 12px ${theme.colors.accentDim}`
@@ -152,8 +153,12 @@ export const DocumentNode = memo(function DocumentNode({ data, selected }: Docum
lineHeight: 1.4,
opacity: 0.85,
overflow: 'hidden' as const,
wordBreak: 'break-word' as const,
overflowWrap: 'break-word' as const,
textOverflow: 'ellipsis' as const,
wordBreak: 'break-all' as const,
overflowWrap: 'anywhere' as const,
display: '-webkit-box' as const,
WebkitLineClamp: 3,
WebkitBoxOrient: 'vertical' as const,
}),
[theme.colors.textDim]
);