diff --git a/.changeset/release-marker-tooltip-wrap.md b/.changeset/release-marker-tooltip-wrap.md new file mode 100644 index 0000000000..14da3bc9de --- /dev/null +++ b/.changeset/release-marker-tooltip-wrap.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/app': patch +--- + +fix: Wrap long values in release marker tooltips instead of overflowing diff --git a/packages/app/src/components/charts/AnnotationTooltip.tsx b/packages/app/src/components/charts/AnnotationTooltip.tsx index 21c858b37a..171b9e3008 100644 --- a/packages/app/src/components/charts/AnnotationTooltip.tsx +++ b/packages/app/src/components/charts/AnnotationTooltip.tsx @@ -8,9 +8,29 @@ import { useChartTooltipZIndex, } from './ChartTooltip'; +import styles from '@styles/HDXLineChart.module.scss'; + /** Gap below the marker so the tooltip does not sit on top of its own label. */ const TOOLTIP_OFFSET_PX = 6; +/** + * Release values are arbitrary attribute values — a version expression that + * concatenates several attributes easily outruns the tooltip's fixed width. + * Wrap rather than overflow: the tooltip is `pointer-events: none`, so the + * scrollbar an overflow produces can never be reached. + * + * `anywhere` rather than `break-word` because only `anywhere` shrinks the + * element's min-content width, which is what the `wrap="nowrap"` row measures. + */ +const wrapLongValue = { overflowWrap: 'anywhere' } as const; + +/** + * Floor for the service name column. Both values share the row's width, so + * without this a long version wraps the service name down to a couple of + * characters per line — the one thing the tooltip exists to say. + */ +const SERVICE_MIN_WIDTH_PX = 80; + /** * Hover tooltip for a release marker: one row per release in the hovered * cluster, each naming the service it belongs to. @@ -45,6 +65,7 @@ export function AnnotationTooltip({ hovered }: { hovered: HoveredAnnotation }) { > } + contentClassName={styles.annotationTooltipContent} > {members.map((member, i) => ( @@ -52,6 +73,7 @@ export function AnnotationTooltip({ hovered }: { hovered: HoveredAnnotation }) { key={member.key ?? `annotation-row-${member.x}-${i}`} gap={8} wrap="nowrap" + align="flex-start" >
{member.group != null && ( - + {member.group} )} - + {member.label} diff --git a/packages/app/src/components/charts/__tests__/AnnotationTooltip.test.tsx b/packages/app/src/components/charts/__tests__/AnnotationTooltip.test.tsx new file mode 100644 index 0000000000..dbd435b8f6 --- /dev/null +++ b/packages/app/src/components/charts/__tests__/AnnotationTooltip.test.tsx @@ -0,0 +1,51 @@ +import { screen } from '@testing-library/react'; + +import type { HoveredAnnotation } from '@/components/charts/AnnotationHitLayer'; +import { AnnotationTooltip } from '@/components/charts/AnnotationTooltip'; + +// A version expression that concatenates several resource attributes produces +// one long unbroken value — the case that used to overflow the fixed-width +// tooltip horizontally. +const LONG_VERSION = + 'v2.14.7-rc.3+build.20260216.a1b2c3d4e5f6-k8s-cluster-eu-west-1-canary'; +const LONG_SERVICE = 'checkout-orchestration-service-eu-west-1-canary'; + +const hovered: HoveredAnnotation = { + annotation: { + time: 1_700_000_000_000, + x: 1_700_000_000, + label: LONG_VERSION, + group: LONG_SERVICE, + color: '#437eef', + }, + point: { x: 100, y: 100 }, +}; + +describe('AnnotationTooltip', () => { + it('wraps long release values instead of overflowing the tooltip width', () => { + renderWithMantine(); + + for (const value of [LONG_VERSION, LONG_SERVICE]) { + const node = screen.getByText(value); + expect(node).not.toHaveStyle({ whiteSpace: 'nowrap' }); + // `anywhere`, not `break-word`: only `anywhere` shrinks the element's + // min-content width, which is what a `wrap="nowrap"` flex row measures. + expect(node).toHaveStyle({ overflowWrap: 'anywhere' }); + } + }); + + it('floors the service name width so a long version cannot squeeze it away', () => { + renderWithMantine(); + + expect(screen.getByText(LONG_SERVICE)).toHaveStyle({ minWidth: '80px' }); + }); + + it('gives the release list more height than the shared series-tooltip cap', () => { + renderWithMantine(); + + expect(screen.getByText(LONG_VERSION).closest('.chartTooltipContent')) + // Wrapped values are several lines tall, so the shared 200px cap clips a + // cluster of releases almost immediately. + .toHaveClass('annotationTooltipContent'); + }); +}); diff --git a/packages/app/styles/HDXLineChart.module.scss b/packages/app/styles/HDXLineChart.module.scss index 1c2817f345..5252031127 100644 --- a/packages/app/styles/HDXLineChart.module.scss +++ b/packages/app/styles/HDXLineChart.module.scss @@ -92,6 +92,12 @@ overflow: hidden; } +// Release-marker tooltip only. Its values wrap over several lines each, so the +// shared cap above clips a cluster of releases almost immediately. +.annotationTooltipContent { + max-height: 500px; +} + .chartTooltipFooter { padding: 6px 12px; border-top: 1px solid var(--color-border);