fix: clip graph node title and subtitle to prevent overflow

Long entity names overflowed past the icon area on graph cards.
Added SVG clipPath to constrain text within the node bounds.
This commit is contained in:
2026-03-25 23:56:30 +03:00
parent 53986f8d95
commit dca2d212b1

View File

@@ -336,10 +336,17 @@ function renderNode(node: GraphNode, callbacks: NodeCallbacks): SVGElement {
g.appendChild(dot);
}
// Clip path for title/subtitle text (prevent overflow past icon area)
const clipId = `clip-text-${id.replace(/[^a-zA-Z0-9_-]/g, '_')}`;
const clipPath = svgEl('clipPath', { id: clipId });
clipPath.appendChild(svgEl('rect', { x: 14, y: 0, width: width - 48, height }));
g.appendChild(clipPath);
// Title (shift left edge for icon to have room)
const title = svgEl('text', {
class: 'graph-node-title',
x: 16, y: 24,
'clip-path': `url(#${clipId})`,
});
title.textContent = name;
g.appendChild(title);
@@ -349,6 +356,7 @@ function renderNode(node: GraphNode, callbacks: NodeCallbacks): SVGElement {
const sub = svgEl('text', {
class: 'graph-node-subtitle',
x: 16, y: 42,
'clip-path': `url(#${clipId})`,
});
sub.textContent = subtype.replace(/_/g, ' ');
g.appendChild(sub);