Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(uplotV2): tooltip list clips last row and over-scrolls (#11883)

Abhi kumar7d8a00ab8c51
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
index 62cf8aaf67..338a4cb016 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
@@ -177,7 +177,8 @@ describe('Tooltip', () => {
renderTooltip({ uPlotInstance, content });
const list = screen.getByTestId('uplot-tooltip-list');
- expect(list).toHaveStyle({ height: '200px' });
+ // Measured height (200) + the scroll viewport's vertical padding (16)
+ expect(list).toHaveStyle({ height: '216px' });
});
it('sets tooltip list height based on content length when Virtuoso reports 0 height', () => {
@@ -188,8 +189,8 @@ describe('Tooltip', () => {
renderTooltip({ uPlotInstance, content });
const list = screen.getByTestId('uplot-tooltip-list');
- // Falls back to content length: 2 items * 38px = 76px
- expect(list).toHaveStyle({ height: '76px' });
+ // Falls back to content length (2 * 38 = 76) + vertical padding (16) = 92px
+ expect(list).toHaveStyle({ height: '92px' });
});
});
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
index 8a2fc40def..4ab5bfc9d4 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
@@ -13,6 +13,11 @@ import Styles from './TooltipList.module.scss';
// Fallback per-item height before Virtuoso reports the real total.
const TOOLTIP_ITEM_HEIGHT = 38;
const LIST_MAX_HEIGHT = 300;
+// Vertical padding (spacing-4 top + bottom) the SCSS applies to the scroll
+// viewport. Virtuoso's reported height covers only the items, so it must be
+// added back — otherwise the box is short by this amount, clipping the last
+// row and showing a scrollbar even when every row would fit.
+const LIST_VERTICAL_PADDING = 16;
interface TooltipListProps {
id: string;
@@ -30,13 +35,13 @@ export default function TooltipList({
// Use the measured height from Virtuoso when available; fall back to a
// per-item estimate on first render. Math.ceil prevents a 1 px
// subpixel rounding gap from triggering a spurious scrollbar.
- const height = useMemo(
- () =>
- totalListHeight > 0
- ? Math.ceil(Math.min(totalListHeight, LIST_MAX_HEIGHT))
- : Math.min(content.length * TOOLTIP_ITEM_HEIGHT, LIST_MAX_HEIGHT),
- [totalListHeight, content.length],
- );
+ const height = useMemo(() => {
+ const contentHeight =
+ totalListHeight > 0 ? totalListHeight : content.length * TOOLTIP_ITEM_HEIGHT;
+ return Math.ceil(
+ Math.min(contentHeight + LIST_VERTICAL_PADDING, LIST_MAX_HEIGHT),
+ );
+ }, [totalListHeight, content.length]);
const handleScroll = useCallback(() => {
if (!isScrollEventTriggered.current) {