Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/release-marker-tooltip-wrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

fix: Wrap long values in release marker tooltips instead of overflowing
32 changes: 30 additions & 2 deletions packages/app/src/components/charts/AnnotationTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -45,29 +65,37 @@ export function AnnotationTooltip({ hovered }: { hovered: HoveredAnnotation }) {
>
<ChartTooltipContainer
header={<ChartTooltipHeader labelSeconds={hovered.annotation.x} />}
contentClassName={styles.annotationTooltipContent}
>
<Stack gap={4}>
{members.map((member, i) => (
<Group
key={member.key ?? `annotation-row-${member.x}-${i}`}
gap={8}
wrap="nowrap"
align="flex-start"
>
<div
style={{
width: 8,
height: 8,
borderRadius: 2,
flexShrink: 0,
// Centres the dot on the row's first line of text.
marginTop: 5,
background: member.color ?? 'var(--color-border)',
}}
/>
{member.group != null && (
<Text size="xs" c="dimmed" style={{ whiteSpace: 'nowrap' }}>
<Text
size="xs"
c="dimmed"
style={{ ...wrapLongValue, minWidth: SERVICE_MIN_WIDTH_PX }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — minWidth set via raw style instead of a Mantine style prop

The Repository conventions say to prefer individual Mantine style props over raw styles. Use miw={SERVICE_MIN_WIDTH_PX} on the Text and keep only overflowWrap in style, since Mantine has no style prop for it.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

>
{member.group}
</Text>
)}
<Text size="xs" fw={500} style={{ whiteSpace: 'nowrap' }}>
<Text size="xs" fw={500} style={wrapLongValue}>
{member.label}
</Text>
</Group>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(<AnnotationTooltip hovered={hovered} />);

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(<AnnotationTooltip hovered={hovered} />);

expect(screen.getByText(LONG_SERVICE)).toHaveStyle({ minWidth: '80px' });
});

it('gives the release list more height than the shared series-tooltip cap', () => {
renderWithMantine(<AnnotationTooltip hovered={hovered} />);

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');
});
});
6 changes: 6 additions & 0 deletions packages/app/styles/HDXLineChart.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 major — Releases past 500px still sit behind a scrollbar nobody can reach

.annotationTooltipContent raises the height cap but keeps the overflow-y: auto it inherits from .chartTooltipContent. The tooltip is pointer-events: none (AnnotationTooltip.tsx:62), and members has no upper bound (chartAnnotations.tsx:222 slices the whole cluster). So a big cluster of wrapped rows still overflows into a scrollbar that can't be used, which is the same problem this PR fixes for width. Do what .chartTooltipContentClipped already does (overflow: hidden), and cap the rendered rows with a "+N more" line so the cut is visible.

Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate fix - and it would be annoying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Release tooltip still gets a scrollbar the pointer can't reach once content passes 500px

.annotationTooltipContent only raises max-height. It still inherits overflow-y: auto from .chartTooltipContent, and the portal wrapper in AnnotationTooltip.tsx sets pointerEvents: 'none'. So when a large release cluster with wrapped values grows past 500px, it gets the same unreachable scrollbar this PR is trying to remove. Add overflow: hidden to match the hover-only .chartTooltipContentClipped rule a few lines above, or reuse that pattern.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

max-height: 500px;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Fixed 500px cap ignores viewport height for a tooltip that never flips

The tooltip is position: fixed and always opens downward from the marker (top: point.y + 6), with no flip or clamp. A 500px list plus the header runs off the bottom of the screen for tiles in the lower part of a dashboard or on short viewports. Before, the 200px cap mostly hid this. Bound it to the viewport the way the series list at line 51 does, e.g. max-height: min(500px, 40vh).

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — 500px tooltip opens below the marker with no viewport clamp

AnnotationHitLayer.tsx anchors the tooltip at the bottom of the label band, which is the top of the chart, and AnnotationTooltip sets top = point.y + 6 with no flip or clamp. For a chart in the lower half of the screen, a tooltip that can now be 500px tall plus its header runs off the bottom of the viewport, and the user can't scroll it. Cap the height relative to the viewport, e.g. max-height: min(500px, calc(100vh - <anchor>)) passed as an inline style, or flip the tooltip above the marker when there isn't room below.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

}

.chartTooltipFooter {
padding: 6px 12px;
border-top: 1px solid var(--color-border);
Expand Down
Loading