Skip to content

Commit 73c8f2a

Browse files
Merge branch 'main' into aaron/stream-filter-key-value-results
2 parents c652777 + 685f465 commit 73c8f2a

4 files changed

Lines changed: 92 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hyperdx/app': patch
3+
---
4+
5+
fix: Wrap long values in release marker tooltips instead of overflowing

‎packages/app/src/components/charts/AnnotationTooltip.tsx‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,29 @@ import {
88
useChartTooltipZIndex,
99
} from './ChartTooltip';
1010

11+
import styles from '@styles/HDXLineChart.module.scss';
12+
1113
/** Gap below the marker so the tooltip does not sit on top of its own label. */
1214
const TOOLTIP_OFFSET_PX = 6;
1315

16+
/**
17+
* Release values are arbitrary attribute values — a version expression that
18+
* concatenates several attributes easily outruns the tooltip's fixed width.
19+
* Wrap rather than overflow: the tooltip is `pointer-events: none`, so the
20+
* scrollbar an overflow produces can never be reached.
21+
*
22+
* `anywhere` rather than `break-word` because only `anywhere` shrinks the
23+
* element's min-content width, which is what the `wrap="nowrap"` row measures.
24+
*/
25+
const wrapLongValue = { overflowWrap: 'anywhere' } as const;
26+
27+
/**
28+
* Floor for the service name column. Both values share the row's width, so
29+
* without this a long version wraps the service name down to a couple of
30+
* characters per line — the one thing the tooltip exists to say.
31+
*/
32+
const SERVICE_MIN_WIDTH_PX = 80;
33+
1434
/**
1535
* Hover tooltip for a release marker: one row per release in the hovered
1636
* cluster, each naming the service it belongs to.
@@ -45,29 +65,37 @@ export function AnnotationTooltip({ hovered }: { hovered: HoveredAnnotation }) {
4565
>
4666
<ChartTooltipContainer
4767
header={<ChartTooltipHeader labelSeconds={hovered.annotation.x} />}
68+
contentClassName={styles.annotationTooltipContent}
4869
>
4970
<Stack gap={4}>
5071
{members.map((member, i) => (
5172
<Group
5273
key={member.key ?? `annotation-row-${member.x}-${i}`}
5374
gap={8}
5475
wrap="nowrap"
76+
align="flex-start"
5577
>
5678
<div
5779
style={{
5880
width: 8,
5981
height: 8,
6082
borderRadius: 2,
6183
flexShrink: 0,
84+
// Centres the dot on the row's first line of text.
85+
marginTop: 5,
6286
background: member.color ?? 'var(--color-border)',
6387
}}
6488
/>
6589
{member.group != null && (
66-
<Text size="xs" c="dimmed" style={{ whiteSpace: 'nowrap' }}>
90+
<Text
91+
size="xs"
92+
c="dimmed"
93+
style={{ ...wrapLongValue, minWidth: SERVICE_MIN_WIDTH_PX }}
94+
>
6795
{member.group}
6896
</Text>
6997
)}
70-
<Text size="xs" fw={500} style={{ whiteSpace: 'nowrap' }}>
98+
<Text size="xs" fw={500} style={wrapLongValue}>
7199
{member.label}
72100
</Text>
73101
</Group>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { screen } from '@testing-library/react';
2+
3+
import type { HoveredAnnotation } from '@/components/charts/AnnotationHitLayer';
4+
import { AnnotationTooltip } from '@/components/charts/AnnotationTooltip';
5+
6+
// A version expression that concatenates several resource attributes produces
7+
// one long unbroken value — the case that used to overflow the fixed-width
8+
// tooltip horizontally.
9+
const LONG_VERSION =
10+
'v2.14.7-rc.3+build.20260216.a1b2c3d4e5f6-k8s-cluster-eu-west-1-canary';
11+
const LONG_SERVICE = 'checkout-orchestration-service-eu-west-1-canary';
12+
13+
const hovered: HoveredAnnotation = {
14+
annotation: {
15+
time: 1_700_000_000_000,
16+
x: 1_700_000_000,
17+
label: LONG_VERSION,
18+
group: LONG_SERVICE,
19+
color: '#437eef',
20+
},
21+
point: { x: 100, y: 100 },
22+
};
23+
24+
describe('AnnotationTooltip', () => {
25+
it('wraps long release values instead of overflowing the tooltip width', () => {
26+
renderWithMantine(<AnnotationTooltip hovered={hovered} />);
27+
28+
for (const value of [LONG_VERSION, LONG_SERVICE]) {
29+
const node = screen.getByText(value);
30+
expect(node).not.toHaveStyle({ whiteSpace: 'nowrap' });
31+
// `anywhere`, not `break-word`: only `anywhere` shrinks the element's
32+
// min-content width, which is what a `wrap="nowrap"` flex row measures.
33+
expect(node).toHaveStyle({ overflowWrap: 'anywhere' });
34+
}
35+
});
36+
37+
it('floors the service name width so a long version cannot squeeze it away', () => {
38+
renderWithMantine(<AnnotationTooltip hovered={hovered} />);
39+
40+
expect(screen.getByText(LONG_SERVICE)).toHaveStyle({ minWidth: '80px' });
41+
});
42+
43+
it('gives the release list more height than the shared series-tooltip cap', () => {
44+
renderWithMantine(<AnnotationTooltip hovered={hovered} />);
45+
46+
expect(screen.getByText(LONG_VERSION).closest('.chartTooltipContent'))
47+
// Wrapped values are several lines tall, so the shared 200px cap clips a
48+
// cluster of releases almost immediately.
49+
.toHaveClass('annotationTooltipContent');
50+
});
51+
});

‎packages/app/styles/HDXLineChart.module.scss‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
overflow: hidden;
9393
}
9494

95+
// Release-marker tooltip only. Its values wrap over several lines each, so the
96+
// shared cap above clips a cluster of releases almost immediately.
97+
.annotationTooltipContent {
98+
max-height: 500px;
99+
}
100+
95101
.chartTooltipFooter {
96102
padding: 6px 12px;
97103
border-top: 1px solid var(--color-border);

0 commit comments

Comments
 (0)