Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Fix summary chart tooltip tracking
rcourtman071284361c59
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 6585f64ecb..6da14ecc9a 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -1244,6 +1244,10 @@ introducing light-mode-inverted palettes.That same tooltip owner now also holds the CSP-safe portal contract: sharedtooltip shells must render through SVG/attribute positioning and viewport-clamped layout helpers rather than fixed inline `left`/`top` style attributes.+When a shared portal tooltip is already visible, that same owner must+reschedule positioning on live coordinate and viewport changes so chart hover+tooltips keep following the active pointer instead of sticking to their first+anchor.The shared collapsible search input now follows that same owner split.`frontend-modern/src/components/shared/CollapsibleSearchInput.tsx` stays therender shell, `frontend-modern/src/components/shared/useCollapsibleSearchInputState.ts`diff --git a/frontend-modern/src/components/shared/__tests__/DensityMap.test.tsx b/frontend-modern/src/components/shared/__tests__/DensityMap.test.tsxindex 8acd8376dd..009dac4ad5 100644--- a/frontend-modern/src/components/shared/__tests__/DensityMap.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/DensityMap.test.tsx@@ -1,4 +1,4 @@-import { fireEvent, render, screen } from '@solidjs/testing-library';+import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import { describe, expect, it, vi } from 'vitest';import densityMapSource from '@/components/shared/DensityMap.tsx?raw';import densityMapModelSource from '@/components/shared/densityMapModel.ts?raw';@@ -96,6 +96,77 @@ describe('DensityMap', () => {expect(document.querySelector('[data-density-map-tooltip-sparkline="true"]')).toBeNull();});+ it('repositions the shared tooltip portal while the density-map hover stays visible', async () => {+ vi.spyOn(window, 'requestAnimationFrame').mockImplementation((callback: FrameRequestCallback) => {+ callback(0);+ return 1;+ });++ const now = Date.now();+ const { container } = render(() => (+ <DensityMap+ timeRange="1h"+ series={[+ {+ id: 'cpu',+ name: 'CPU',+ color: '#10b981',+ data: [+ { timestamp: now - 30_000, value: 25 },+ { timestamp: now - 10_000, value: 55 },+ ],+ },+ {+ id: 'memory',+ name: 'Memory',+ color: '#f59e0b',+ data: [+ { timestamp: now - 30_000, value: 45 },+ { timestamp: now - 10_000, value: 65 },+ ],+ },+ ]}+ />+ ));++ const canvas = container.querySelector('canvas');+ expect(canvas).not.toBeNull();+ if (!canvas) return;++ (canvas as unknown as { getBoundingClientRect: () => DOMRect }).getBoundingClientRect = () =>+ ({+ left: 0,+ top: 0,+ width: 180,+ height: 80,+ right: 180,+ bottom: 80,+ x: 0,+ y: 0,+ toJSON: () => ({}),+ }) as unknown as DOMRect;++ const readTooltipTop = () =>+ Number.parseFloat(+ document+ .querySelector('[data-density-map-tooltip="true"]')+ ?.closest('foreignObject')+ ?.getAttribute('y') || 'NaN',+ );++ fireEvent.mouseMove(canvas, { clientX: 160, clientY: 10 });+ await waitFor(() => {+ expect(document.querySelector('[data-density-map-tooltip="true"]')).not.toBeNull();+ });+ const firstTop = readTooltipTop();++ fireEvent.mouseMove(canvas, { clientX: 160, clientY: 70 });++ await waitFor(() => {+ expect(readTooltipTop()).toBeGreaterThan(firstTop + 20);+ });+ });+it('publishes synchronized hover identity and clears it on leave', () => {const now = Date.now();const onHoverSyncChange = vi.fn();diff --git a/frontend-modern/src/components/shared/__tests__/TooltipPortal.test.tsx b/frontend-modern/src/components/shared/__tests__/TooltipPortal.test.tsxindex cf61bbc6b2..e9f5324d64 100644--- a/frontend-modern/src/components/shared/__tests__/TooltipPortal.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/TooltipPortal.test.tsx@@ -96,4 +96,57 @@ describe('TooltipPortal', () => {expect(raf).toHaveBeenCalled();expect(getBoundingClientRect).toHaveBeenCalled();});++ it('repositions while the portal stays visible and coordinates keep changing', async () => {+ vi.spyOn(window, 'requestAnimationFrame').mockImplementation((callback: FrameRequestCallback) => {+ callback(0);+ return 1;+ });++ vi.spyOn(HTMLDivElement.prototype, 'getBoundingClientRect').mockReturnValue({+ width: 180,+ height: 40,+ left: 0,+ top: 0,+ right: 180,+ bottom: 40,+ x: 0,+ y: 0,+ toJSON: () => ({}),+ } as DOMRect);++ const [x, setX] = createSignal(180);+ const [y, setY] = createSignal(120);++ render(() => (+ <TooltipPortal when x={x()} y={y()}>+ <span>Memory Composition</span>+ </TooltipPortal>+ ));++ const readPortalPosition = () => {+ const portal = document.body.querySelector('foreignObject');+ return {+ x: Number.parseFloat(portal?.getAttribute('x') ?? 'NaN'),+ y: Number.parseFloat(portal?.getAttribute('y') ?? 'NaN'),+ };+ };++ await waitFor(() => {+ const position = readPortalPosition();+ expect(position.x).toBeGreaterThan(0);+ expect(position.y).toBeGreaterThan(0);+ });++ const initialPosition = readPortalPosition();++ setX(320);+ setY(220);++ await waitFor(() => {+ const position = readPortalPosition();+ expect(position.x).toBeGreaterThan(initialPosition.x + 100);+ expect(position.y).toBeGreaterThan(initialPosition.y + 80);+ });+ });});diff --git a/frontend-modern/src/components/shared/useTooltipState.ts b/frontend-modern/src/components/shared/useTooltipState.tsindex eef693adac..cf0a7bea93 100644--- a/frontend-modern/src/components/shared/useTooltipState.ts+++ b/frontend-modern/src/components/shared/useTooltipState.ts@@ -45,6 +45,7 @@ function useTooltipLayoutState(options: TooltipLayoutStateOptions): {viewport: Accessor<TooltipViewportRect>;} {let tooltipRef: HTMLDivElement | undefined;+ let positionRafId: number | null = null;const [position, setPosition] = createSignal<TooltipPosition>({ left: 0, top: 0 });const [viewport, setViewport] = createSignal<TooltipViewportRect>({height: typeof window === 'undefined' ? 0 : window.innerHeight,@@ -73,21 +74,59 @@ function useTooltipLayoutState(options: TooltipLayoutStateOptions): {);};+ const schedulePositionUpdate = () => {+ if (typeof window === 'undefined') return;+ if (positionRafId !== null) {+ window.cancelAnimationFrame(positionRafId);+ }+ positionRafId = window.requestAnimationFrame(() => {+ positionRafId = null;+ updatePosition();+ });+ };+createEffect(() => {if (typeof window === 'undefined') return;updateViewport();- const handleResize = () => updateViewport();+ const handleResize = () => {+ updateViewport();+ if (options.visible()) {+ schedulePositionUpdate();+ }+ };window.addEventListener('resize', handleResize);onCleanup(() => window.removeEventListener('resize', handleResize));});createEffect(() => {- if (!options.visible()) {- setPosition({ left: options.x(), top: options.y() });+ const visible = options.visible();+ // Read the live layout inputs here so pointer-driven coordinate changes+ // retrigger portal positioning while the tooltip remains visible.+ const layoutInputs = {+ align: options.align(),+ direction: options.direction(),+ maxWidth: options.maxWidth(),+ x: options.x(),+ y: options.y(),+ };++ if (!visible) {+ if (typeof window !== 'undefined' && positionRafId !== null) {+ window.cancelAnimationFrame(positionRafId);+ positionRafId = null;+ }+ setPosition({ left: layoutInputs.x, top: layoutInputs.y });return;}- requestAnimationFrame(updatePosition);+ schedulePositionUpdate();+ });++ onCleanup(() => {+ if (typeof window !== 'undefined' && positionRafId !== null) {+ window.cancelAnimationFrame(positionRafId);+ positionRafId = null;+ }});return {@@ -97,7 +136,7 @@ function useTooltipLayoutState(options: TooltipLayoutStateOptions): {setTooltipRef: (el) => {tooltipRef = el;if (options.visible()) {- requestAnimationFrame(updatePosition);+ schedulePositionUpdate();}},viewport,diff --git a/tests/integration/tests/48-summary-hover-selection.spec.ts b/tests/integration/tests/48-summary-hover-selection.spec.tsindex 1601cda112..933ba904ed 100644--- a/tests/integration/tests/48-summary-hover-selection.spec.ts+++ b/tests/integration/tests/48-summary-hover-selection.spec.ts@@ -386,18 +386,18 @@ async function expectSparklineTooltipTracksPointer(}const tooltip = page.locator('[data-sparkline-tooltip="true"]').last();+ const readTooltipTop = async () =>+ tooltip.evaluate((node) =>+ Number.parseFloat(node.closest("foreignObject")?.getAttribute("y") || "NaN"),+ );await page.mouse.move(box.x + box.width * 0.45, box.y + box.height * 0.2);await expect(tooltip).toBeVisible();- const firstTop = await tooltip.evaluate((node) =>- Number.parseFloat((node as HTMLElement).style.top || "NaN"),- );+ const firstTop = await readTooltipTop();await page.mouse.move(box.x + box.width * 0.45, box.y + box.height * 0.75);await expect(tooltip).toBeVisible();- const secondTop = await tooltip.evaluate((node) =>- Number.parseFloat((node as HTMLElement).style.top || "NaN"),- );+ const secondTop = await readTooltipTop();expect(secondTop).toBeGreaterThan(firstTop + 40);await page.mouse.move(1, 1);