Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Drop the summary focus bridge members nothing reads

rcourtmanaafa4793c3de
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2d7ffe53ea..1820eee94e 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -3011,9 +3011,9 @@ Agent`), with the plain-language source phrase available through accessible
than receiving an unfiltered copy of the estate. Opaque unified-resource ids
are not part of that visible search vocabulary and must not retain a node
when the normalized guest table has no corresponding match.
-8. Keep summary interaction identity on one shared helper. Pages that expose row-hover, group-hover, or route-focus-driven summary emphasis, today the Workloads and Storage tables through `useSummaryPageInteractionState` in `frontend-modern/src/components/shared/summaryTableFocus.ts`, must derive page/group/entity scope through `frontend-modern/src/components/shared/summaryCardInteraction.ts` rather than letting each surface read `hovered || focused` from its own page-local ID source. Hovering or pinning a storage pool-group header, or a workload group header on a surface that enables inline group drawers (the Proxmox and VMware surfaces pass `groupNodeDrawerMode="disabled"` today), must scope the matching rows through that same shared contract instead of forking a page-local summary filter path. No summary card or chart strip renders today; one that returns must consume that same resolved scope, and the chart under the pointer must promote its series into the shared active entity through the bridge's `setChartHoverSync` input instead of keeping a chart-local hover island. Recovery is explicitly outside this interaction dialect: its retired posture-card strip must not return with row/group/chart hover behavior without a separate governed product decision.
+8. Keep summary interaction identity on one shared helper. Pages that expose row-hover, group-hover, or route-focus-driven summary emphasis, today the Workloads and Storage tables through `useSummaryPageInteractionState` in `frontend-modern/src/components/shared/summaryTableFocus.ts`, must derive page/group/entity scope through `frontend-modern/src/components/shared/summaryCardInteraction.ts` rather than letting each surface read `hovered || focused` from its own page-local ID source. Hovering or pinning a storage pool-group header, or a workload group header on a surface that enables inline group drawers (the Proxmox and VMware surfaces pass `groupNodeDrawerMode="disabled"` today), must scope the matching rows through that same shared contract instead of forking a page-local summary filter path. No summary card or chart strip renders today, and the bridge carries no chart-hover input; one that returns must consume that same resolved scope, and the chart under the pointer must enter its hovered series into `resolveSummaryScopeState` as a preview input that outranks row hover instead of keeping a chart-local hover island. Recovery is explicitly outside this interaction dialect: its retired posture-card strip must not return with row/group/chart hover behavior without a separate governed product decision.
9. Keep any page summary page-scoped when table rows enter contextual focus. No infrastructure, workloads, or storage summary cards render today. If one returns, route-backed row selection may add a focused label and shared series emphasis, but the summary must continue to render the page-level series set instead of collapsing down to the selected row or replacing the global trend view with row-local empty states.
-10. Keep contextual row focus on the shared primitives. Same-route table drill-ins must reuse `frontend-modern/src/components/shared/contextualFocus.ts` for local scroll preservation, off-screen reveal, inline-detail lookup, and deliberate inline-detail reveal, and must resolve the active series through `frontend-modern/src/components/shared/summaryCardInteraction.ts` behind `frontend-modern/src/components/shared/summaryTableFocus.ts`, instead of rebuilding page-local `Set` filters, focused-label scans, drawer-aware scroll math, or ad hoc scroll restoration in each surface.
+10. Keep contextual row focus on the shared primitives. Same-route table drill-ins must reuse `frontend-modern/src/components/shared/contextualFocus.ts` for local scroll preservation, off-screen reveal, inline-detail lookup, and deliberate inline-detail reveal, and must resolve the active series through `frontend-modern/src/components/shared/summaryCardInteraction.ts` behind `frontend-modern/src/components/shared/summaryTableFocus.ts`, instead of rebuilding page-local `Set` filters, focused-label scans, drawer-aware scroll math, or ad hoc scroll restoration in each surface. `frontend-modern/src/components/shared/summaryTableFocus.ts` measures and scrolls rows only for deliberate focus, a focused row's inline detail or a pinned group header, so it must not keep window-level scroll or resize listeners or re-measure the hovered row on hover changes and scroll frames; an off-screen affordance for the active row needs a rendered consumer before that cost returns.
11. Keep summary-linked table row emphasis on the shared primitive contract. Workloads, infrastructure, and storage rows that mirror the active summary entity must expose that state through `data-summary-row-active` and let the shared presentation in `frontend-modern/src/index.css` render the row emphasis, rather than carrying page-local sky or blue fill classes inside each row renderer. Group-scoped preview and pin must use that same shared presentation boundary: child rows that belong to a hovered or pinned summary group should expose `data-summary-group-member-active="preview|pinned"` so the block-level emphasis stays subtle, consistent, and reversible instead of each table inventing its own outline, badge, or full-strength fill treatment. Static grouped row headers on workloads, infrastructure, storage, recovery, and future grouped tables must use `frontend-modern/src/components/shared/groupedTableRowPresentation.ts` plus the `.grouped-table-row` CSS contract in `frontend-modern/src/index.css`, rather than rebuilding local `bg-surface-alt` variants with subtly different light/dark behavior or page-local left-accent markers. That shared grouped-table primitive owns the subgroup cell padding, typography, small metadata, and badge treatment as well as the row background token, so a future adjustment to the subgroup visual language changes every grouped product table from one owner. Inline table detail rows on platform, workload, and infrastructure tables must compose `frontend-modern/src/components/shared/InlineDetailTableRow.tsx` for the full-width row, surface-alt cell, detail padding, and row-click containment instead of rebuilding page-local `TableRow` / `TableCell` / `div` shells around each drawer. Storage-backed reusable row presenters under `frontend-modern/src/features/storageBackups/` must also keep row height and alert accents on class/data-attribute presentation instead of runtime inline style maps, so the shared table contract stays CSP-safe on both steady-state and alert-highlighted routes.
12. Keep retained-value data loading honest at the ownership boundary. Helpers
that prevent a feature surface from falling through the app-level Suspense
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index ef776a8f02..60fb19434d 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -2408,6 +2408,12 @@ workloads and storage tables. Row hover may highlight the matching row in
place, but the hot path must not auto-scroll the page or rebuild the table
into a one-row filtered view on transient hover; only a deliberate row focus
may reveal an off-screen row, through the shared summary-table focus bridge.
+The bridge measures row position only inside that deliberate reveal. It must
+not keep window-level scroll or resize listeners, or re-measure the hovered
+row on every hover change and scroll frame, for an off-screen affordance that
+nothing renders: the retired `Jump to row` visibility check did exactly that,
+costing 128 `getComputedStyle` calls across eight row hovers and 320 across
+ten scroll steps on the 12-node mock storage table, and none once removed.
That same hot-path contract also owns the row-emphasis paint. Workload guest
and group rows and storage pool, group, and disk rows must expose
summary-linked activity through the shared `data-summary-row-active` marker and let the shared frontend
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d1199c9224..e730514596 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -4356,10 +4356,13 @@ one that returns must stay page-scoped instead of collapsing to the expanded
row or replacing the page overview with row-local empty states.
That same storage ownership now also governs reveal. Row hover may highlight
the matching row in place, but storage hover must not auto-filter or
-auto-scroll the table. Reveal belongs only to deliberate focus: a focused
-pool or disk row may switch to the owning view or expand the owning group
-through the bridge's `revealActiveSeries` callback, and a pinned pool-group
-header that sits off-screen scrolls into view through the same bridge.
+auto-scroll the table. Reveal belongs only to deliberate focus: the bridge
+hands the focused pool or disk series to the `revealActiveSeries` callback,
+which reopens a focused pool's collapsed owning group, and a pinned pool-group
+header that sits off-screen scrolls into view through the same bridge. Focus
+only ever names a row in the active pools or disks view, so the callback never
+switches views; the view-switching branches that served the retired jump to
+the active row are gone.
That same reveal contract now also owns inline-detail expansion. When a pool or
disk row is deliberately focused and its inline detail opens on the storage
page, the detail row must publish the same canonical summary series ID through
diff --git a/frontend-modern/browser-verification/2cb610e77c51ad5f.json b/frontend-modern/browser-verification/2cb610e77c51ad5f.json
new file mode 100644
index 0000000000..afde001442
--- /dev/null
+++ b/frontend-modern/browser-verification/2cb610e77c51ad5f.json
@@ -0,0 +1,56 @@
+{
+ "version": 1,
+ "base_sha": "48c2d6cdce8d019151e3567873de88e21b76bb22",
+ "verified_at": "2026-10-07T18:53:57Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Storage/useStoragePageModel.ts",
+ "frontend-modern/src/components/shared/contextualFocus.ts",
+ "frontend-modern/src/components/shared/summaryCardInteraction.ts",
+ "frontend-modern/src/components/shared/summaryTableFocus.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Storage/useStoragePageModel.ts": "9f4734cf74cb44b7db9222bd08d25fa2ae52d787e192bd07e36640e2e81cde6d",
+ "frontend-modern/src/components/shared/contextualFocus.ts": "4dc89355f978c9dfee90cb0c780976504ac4e7e158bbe7ddf02d566c57211fff",
+ "frontend-modern/src/components/shared/summaryCardInteraction.ts": "9e4f4f9275cd01f2a19b98c1c795eec5c7f37be8f5a002170a94f400bdae4625",
+ "frontend-modern/src/components/shared/summaryTableFocus.ts": "52c46c227696b5dc9713d0cc3d9b76e434fecafeeda46edb064858b0328732ee"
+ },
+ "routes": [
+ "/proxmox/storage",
+ "/proxmox/storage?tab=disks",
+ "/proxmox/storage?group=node&resource=ceph-rbd",
+ "/proxmox/storage?resource=ceph-rbd",
+ "/proxmox/storage?group=node",
+ "/proxmox/storage?group=node&summaryGroup=storage:node:West%20Production%20F",
+ "/proxmox",
+ "/proxmox?resource=<guest id>"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Private 12-node mock stack (backend :7783, Vite :5323 from the landing clone). One Playwright scenario script ran with the four runtime files swapped back to origin/main (before) and with this change (after) at 1440x900 and 390x844, then again after rebasing onto 71a723abb1 with the backend rebuilt from that tree; the final parent adds only #2677 (Patrol correlation fetch), which touches none of these files; no page errors in any run",
+ "Storage pools: hovering 8 rows marks each data-summary-row-active and never moves the page; clicking a lower pool opens its inline detail and scrolls just enough to show the row header and top of the detail; Escape closes it; identical before and after",
+ "Storage deep link ?resource=ceph-rbd opens the Ceph pool detail in view; with group=node, clicking a group header pins it (summaryGroup in the URL, header marked active); a summaryGroup deep link pins and scrolls toward the last group, landing the header in or just below view with the same timing spread before and after",
+ "Storage Physical Disks: clicking a lower disk opens its detail with the same reveal, and focus stays on the Physical Disks view; pool focus stays on the pools view; identical before and after",
+ "Storage in-app link: with group=node, collapsing the shared group with its disclosure button hides ceph-rbd; a client-side navigation to ?resource=ceph-rbd then reopens the group and lands the Ceph pool detail in view, at both widths, identical before and after",
+ "Workloads (/proxmox): hovering guest rows marks them active; clicking a lower guest opens its inline drawer in view and Escape closes it; a ?resource deep link opens the drawer in view; identical before and after",
+ "Cost: window scroll listeners drop from 2 to 1 and resize by one on both pages; getComputedStyle calls during 8 row hovers fall 128 to 0 (Storage) and 175-193 to 13-39 (Workloads), during 10 scroll steps 320 to 0 and 274-472 to 130",
+ "Pre-existing on main and unchanged here: with a pool open, Storage scrolls itself back to it a few seconds after scrolling away (disks view and Workloads do not), and collapsing the group holding the open pool bounces it open; traced to the reveal effect tracking reads inside revealActiveSeries, left for a follow-up"
+ ],
+ "interactions": [
+ "Hovered 8 rows then scrolled the app shell 10 steps on Storage and Workloads with window listener and getComputedStyle counters installed before load",
+ "Clicked a pool row, a physical disk row and a guest row near the bottom, measured the row and detail rectangles, pressed Escape",
+ "Loaded the ceph-rbd, summaryGroup and guest resource deep links, repeating the summaryGroup link four times per width",
+ "Collapsed the shared storage group via its disclosure button, then pushed /proxmox/storage?group=node&resource=ceph-rbd through the router",
+ "Clicked a storage group header to pin it, and clicked the header of the group holding an open pool",
+ "Scrolled the shell to the top with a pool, a disk and a guest open and sampled the scroll position every 500 ms for 12 s"
+ ]
+}
diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
index 5b4b65d38e..277c0171a2 100644
--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
@@ -1,4 +1,5 @@
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { ChartsAPI } from '@/api/charts';
import storageSummarySource from '@/components/Storage/useStorageSummaryCharts.ts?raw';
@@ -57,6 +58,9 @@ if (typeof HTMLCanvasElement.prototype.getContext === 'function') {
let mockLocationSearch = '';
let mockLocationPath = '/proxmox/storage';
+// Most tests read a location snapshot; set liveLocation to follow in-app navigation.
+let liveLocation = false;
+const [locationVersion, setLocationVersion] = createSignal(0);
const navigateSpy = vi.fn();
let wsConnected = true;
@@ -296,7 +300,19 @@ vi.mock('@solidjs/router', async () => {
const actual = await vi.importActual<typeof import('@solidjs/router')>('@solidjs/router');
return {
...actual,
- useLocation: () => ({ pathname: mockLocationPath, search: mockLocationSearch }),
+ useLocation: () =>
+ liveLocation
+ ? {
+ get pathname() {
+ locationVersion();
+ return mockLocationPath;
+ },
+ get search() {
+ locationVersion();
+ return mockLocationSearch;
+ },
+ }
+ : { pathname: mockLocationPath, search: mockLocationSearch },
useNavigate: () => navigateSpy,
};
});
@@ -388,6 +404,7 @@ describe('Storage', () => {
fetchMock.mockClear();
mockLocationPath = '/proxmox/storage';
mockLocationSearch = '';
+ liveLocation = false;
navigateSpy.mockReset();
wsConnected = true;
@@ -825,6 +842,41 @@ describe('Storage', () => {
).not.toBeInTheDocument();
});
+ it('reopens the collapsed group of a pool focused by an in-app storage link', async () => {
+ liveLocation = true;
+ hookResources = [
+ buildStorageResource('storage-ceph-link', 'Ceph-Link-Store', 'pve1', {
+ storageType: 'cephfs',
+ }),
+ buildStorageResource('storage-other', 'Other-Store', 'pve2'),
+ ];
+ mockLocationSearch = '?group=node';
+
+ render(() => <Storage />);
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Collapse pve1' }));
+ await waitFor(() => {
+ expect(screen.queryByText('Ceph-Link-Store')).not.toBeInTheDocument();
+ });
+
+ mockLocationSearch = '?group=node&resource=storage-ceph-link';
+ setLocationVersion((version) => version + 1);
+
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'Collapse pve1' })).toBeInTheDocument();
+ const poolRow = screen.getByText('Ceph-Link-Store').closest('tr[data-summary-series-id]');
+ expect(
+ document
+ .querySelector('tr[data-inline-detail-for]')
+ ?.getAttribute('data-inline-detail-for'),
+ ).toBe(poolRow?.getAttribute('data-summary-series-id'));
+ });
+ expect(screen.getAllByRole('tab', { name: 'Storage' })[0]).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ });
+
it('clears pinned storage group scope from the content-card header action', async () => {
hookResources = [
buildStorageResource('storage-1', 'Node-Store', 'pve1'),
diff --git a/frontend-modern/src/components/Storage/useStoragePageModel.ts b/frontend-modern/src/components/Storage/useStoragePageModel.ts
index d288072e34..3cc8e78cec 100644
--- a/frontend-modern/src/components/Storage/useStoragePageModel.ts
+++ b/frontend-modern/src/components/Storage/useStoragePageModel.ts
@@ -209,13 +209,6 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
}
return keys;
});
- const physicalDiskSeriesIds = createMemo(() => {
- const ids = new Set<string>();
- for (const disk of physicalDisks()) {
- ids.add(resolvePhysicalDiskMetricResourceId(disk));
- }
- return ids;
- });
const storageSummaryGroupScopes = createMemo<Map<string, SummarySeriesGroupScope>>(() => {
if (view() !== 'pools' || groupBy() === 'none') {
return new Map<string, SummarySeriesGroupScope>();
@@ -409,21 +402,13 @@ export const useStoragePageModel = (options: UseStoragePageModelOptions = {}) =>
focusedSeriesId: focusedStorageResourceId,
onEscapeClear: clearAllPageStateOnEscape,
revealActiveSeries: (seriesId) => {
- if (physicalDiskSeriesIds().has(seriesId)) {
- if (view() !== 'disks') {
- setView('disks');
- }
+ // Focus only ever names a row in the active view, so reveal never
+ // switches views; it reopens a focused pool's collapsed group.
+ if (view() !== 'pools') {
return;
}
-
const groupKey = storageGroupKeyByMetricSeriesId().get(seriesId);
- if (!groupKey) {
- return;
- }
- if (view() !== 'pools') {
- setView('pools');
- }
- if (!expandedGroups().has(groupKey)) {
+ if (groupKey && !expandedGroups().has(groupKey)) {
toggleGroup(groupKey);
}
},
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index d0f28a031d..92e324da2c 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -1350,7 +1350,6 @@ describe('shared primitive guardrails', () => {
expect(contextualFocusSource).toContain('export const revealInlineDetailInViewport');
expect(contextualFocusSource).toContain('markRouteStateDeliberateScroll');
expect(contextualFocusSource).toContain('data-inline-detail-for');
- expect(summaryCardInteractionSource).toContain('chartHoveredSeriesId');
expect(summaryCardInteractionSource).toContain('SummarySeriesGroupScope');
expect(summaryCardInteractionSource).toContain('resolveSummaryGroupScope');
expect(summaryCardInteractionSource).toContain('resolveSummaryGroupMemberInteractionState');
@@ -1364,7 +1363,6 @@ describe('shared primitive guardrails', () => {
expect(summaryTableFocusSource).toContain('export function useSummaryTableFocusBridge');
expect(summaryTableFocusSource).toContain('export function useSummaryPageInteractionState');
expect(summaryTableFocusSource).toContain('resolveSummaryActiveSeriesId');
- expect(summaryTableFocusSource).toContain('activeScopeState');
expect(summaryTableFocusSource).toContain('focusedSeriesId');
expect(summaryTableFocusSource).toContain('findInlineDetailElement');
expect(summaryTableFocusSource).toContain('revealInlineDetailInViewport');
@@ -1376,8 +1374,9 @@ describe('shared primitive guardrails', () => {
expect(summaryTableFocusSource).toContain("event.key !== 'Escape'");
expect(summaryTableFocusSource).toContain('querySelector<HTMLElement>(');
expect(summaryTableFocusSource).toContain(
- "row.scrollIntoView({ behavior: 'smooth', block: 'center' })",
+ "row.scrollIntoView({ behavior: 'smooth', block: 'nearest' })",
);
+ expect(summaryTableFocusSource).not.toContain("window.addEventListener('scroll'");
expect(summaryTableFocusSource).not.toContain('useNavigate(');
});
diff --git a/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.branchcov0724pm.test.ts b/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.branchcov0724pm.test.ts
index 33283ace20..8b995327f5 100644
--- a/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.branchcov0724pm.test.ts
+++ b/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.branchcov0724pm.test.ts
@@ -185,12 +185,12 @@ describe('summaryCardInteraction.branchcov0724pm', () => {
});
});
- it('prefers a valid chartHoveredSeriesId over the hoveredGroupScope group return, confirming b37 is precedence-gated (regression guard)', () => {
- // chartHoveredSeriesId 'alpha' is in the resolved scope -> entity/preview
+ it('prefers a hovered series inside the scope over the hoveredGroupScope group return, confirming b37 is precedence-gated (regression guard)', () => {
+ // hoveredSeriesId 'alpha' is in the resolved scope -> entity/preview
// return wins; the hoveredGroupScope group arm (b37) is NOT taken here.
expect(
resolveSummaryScopeState({
- chartHoveredSeriesId: 'alpha',
+ hoveredSeriesId: 'alpha',
hoveredGroupScope: validScope,
}),
).toEqual({
diff --git a/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.test.ts b/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.test.ts
index a1fe5684e5..9d8c2d4417 100644
--- a/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.test.ts
+++ b/frontend-modern/src/components/shared/__tests__/summaryCardInteraction.test.ts
@@ -23,14 +23,6 @@ describe('summaryCardInteraction', () => {
});
it('prefers hovered series ids and falls back to focused ids', () => {
- expect(
- resolveSummaryActiveSeriesId({
- chartHoveredSeriesId: 'gamma',
- hoveredSeriesId: 'beta',
- focusedSeriesId: 'alpha',
- }),
- ).toBe('gamma');
-
expect(
resolveSummaryActiveSeriesId({
hoveredSeriesId: 'beta',
@@ -71,8 +63,7 @@ describe('summaryCardInteraction', () => {
expect(
resolveSummaryScopeState({
- chartHoveredSeriesId: 'beta',
- hoveredSeriesId: 'alpha',
+ hoveredSeriesId: 'beta',
focusedSeriesId: 'alpha',
hoveredGroupScope: groupScope,
focusedGroupScope: groupScope,
diff --git a/frontend-modern/src/components/shared/__tests__/summaryTableFocus.branchcov0723pm.test.ts b/frontend-modern/src/components/shared/__tests__/summaryTableFocus.branchcov0723pm.test.ts
index 09d1b4455f..5b5c58a922 100644
--- a/frontend-modern/src/components/shared/__tests__/summaryTableFocus.branchcov0723pm.test.ts
+++ b/frontend-modern/src/components/shared/__tests__/summaryTableFocus.branchcov0723pm.test.ts
@@ -9,12 +9,9 @@ import {
// Branch-coverage tests for the UNCOVERED guard arms of summaryTableFocus.ts.
// The existing spec (summaryTableFocus.test.tsx) exercises the happy paths;
// this file targets the null/empty/early-return arms that never fire there:
-// - scheduleViewportRefresh (scroll/resize -> viewportVersion tick) — the
-// primary measured gap; never invoked by the existing suite.
-// - activeRow / focusedGroupRow guards: missing container ref, empty id,
-// querySelector miss, attribute-selector escaping.
-// - jumpToActiveRow: no-active-id no-op + frame-exhaustion arm.
-// - shouldShowJumpToActiveRow: empty summary collections + already-visible.
+// - focusedGroupRow guards: missing container ref, empty id, querySelector
+// miss, attribute-selector escaping.
+// - page-default and hover-only active series resolution.
// - Escape handler: defaultPrevented, every modifier arm, dialog target.
// Every asserted value below is hand-computed against the source in
// src/components/shared/summaryTableFocus.ts — no snapshots, no constant-
@@ -50,326 +47,140 @@ describe('summaryTableFocus.branchcov0723pm', () => {
});
// -------------------------------------------------------------------------
- // PRIMARY TARGET: scheduleViewportRefresh
- // (createEffect at summaryTableFocus.ts:226). The existing spec never
- // dispatches scroll/resize after mounting a table root, so the entire
- // effect body — listener registration, the rAF callback that ticks
- // viewportVersion, the dedup guard, and the cancel-on-cleanup arm — is
- // uncovered.
+ // focusedGroupRow guard arms: missing container ref, empty id, querySelector
+ // miss, attribute-selector escaping.
// -------------------------------------------------------------------------
- describe('scheduleViewportRefresh', () => {
- it('ticks viewportVersion via the rAF callback after a scroll event, recomputing isActiveRowVisible', () => {
- // Deferred rAF: capture the callback so we control when viewportVersion
- // increments (the synchronous default stub would tick instantly and hide
- // the dedup arm tested below).
- const scheduled: FrameRequestCallback[] = [];
- let nextId = 7;
- vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
- scheduled.push(cb);
- return nextId++;
- });
-
- const root = document.createElement('div');
- const row = document.createElement('div');
- row.setAttribute('data-summary-series-id', 'workload-a');
- let rowTop = 1200; // below innerHeight(800) -> not visible
- Object.defineProperty(row, 'getBoundingClientRect', {
- configurable: true,
- value: () => buildRect(rowTop),
- });
- root.appendChild(row);
- document.body.appendChild(root);
-
- const [hoveredSeriesId] = createSignal<string | null>('workload-a');
- const { result } = renderHook(() => useSummaryPageInteractionState({ hoveredSeriesId }));
- result.setTableRootRef(root);
-
- // Row below the viewport -> jump affordance shown.
- expect(result.shouldShowJumpToActiveRow()).toBe(true);
-
- // Slide the row into the viewport. The memo must NOT pick this up yet
- // because viewportVersion has not ticked (no rAF has fired).
- rowTop = 64;
- expect(result.shouldShowJumpToActiveRow()).toBe(true);
-
- // scroll -> scheduleViewportRefresh schedules exactly one rAF.
- window.dispatchEvent(new Event('scroll'));
- expect(scheduled).toHaveLength(1);
-
- // Fire the rAF -> viewportVersion++ -> isActiveRowVisible recomputes ->
- // row is now in-viewport -> affordance hidden.
- scheduled[0](0);
- expect(result.shouldShowJumpToActiveRow()).toBe(false);
- });
-
- it('coalesces back-to-back scroll events into a single rAF (rafId !== undefined dedup arm)', () => {
- const scheduled: FrameRequestCallback[] = [];
- let nextId = 3;
- vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
- scheduled.push(cb);
- return nextId++;
- });
-
- const root = document.createElement('div');
- document.body.appendChild(root);
-
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => null }),
- );
- result.setTableRootRef(root);
-
- window.dispatchEvent(new Event('scroll'));
- window.dispatchEvent(new Event('scroll'));
- window.dispatchEvent(new Event('scroll'));
-
- // Only the first scroll schedules an rAF; subsequent ones hit
- // `if (rafId !== undefined) return;` while the callback is pending.
- expect(scheduled).toHaveLength(1);
- });
-
- it('refreshes viewportVersion on window resize as well as scroll (resize listener arm)', () => {
- const scheduled: FrameRequestCallback[] = [];
- let nextId = 11;
- vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
- scheduled.push(cb);
- return nextId++;
- });
-
- const root = document.createElement('div');
- const row = document.createElement('div');
- row.setAttribute('data-summary-series-id', 'workload-a');
- let rowTop = 900;
- Object.defineProperty(row, 'getBoundingClientRect', {
- configurable: true,
- value: () => buildRect(rowTop),
- });
- root.appendChild(row);
- document.body.appendChild(root);
-
- const [hoveredSeriesId] = createSignal<string | null>('workload-a');
- const { result } = renderHook(() => useSummaryPageInteractionState({ hoveredSeriesId }));
- result.setTableRootRef(root);
- expect(result.shouldShowJumpToActiveRow()).toBe(true);
-
- rowTop = 50;
- window.dispatchEvent(new Event('resize'));
- expect(scheduled).toHaveLength(1);
- scheduled[0](0);
- expect(result.shouldShowJumpToActiveRow()).toBe(false);
- });
-
- it('cancels the pending rAF id when the owner is disposed (cancelAnimationFrame cleanup arm)', () => {
- const scheduled: FrameRequestCallback[] = [];
- const cancelSpy = vi.fn();
- const pendingId = 42;
- vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => {
- scheduled.push(cb);
- return pendingId;
- });
- vi.stubGlobal('cancelAnimationFrame', cancelSpy);
-
- const root = document.createElement('div');
- document.body.appendChild(root);
-
- const { result, cleanup } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => null }),
- );
- result.setTableRootRef(root);
-
- window.dispatchEvent(new Event('scroll'));
- expect(cancelSpy).not.toHaveBeenCalled();
-
- cleanup();
-
- // The rAF id returned by the deferred stub (42) is cancelled on dispose.
- expect(cancelSpy).toHaveBeenCalledWith(pendingId);
- });
-
- it('does not attach scroll/resize listeners when tableRoot ref is missing (missing container ref arm)', () => {
+ describe('focusedGroupRow guard arms', () => {
+ it('does not attempt a reveal when setTableRootRef receives undefined (setter `element ?? null` right arm)', () => {
const rafSpy = vi.fn((cb: FrameRequestCallback) => {
cb(0);
return 1;
});
vi.stubGlobal('requestAnimationFrame', rafSpy);
- renderHook(() => useSummaryTableFocusBridge({ activeSeriesId: () => null }));
+ const [focusedGroupId] = createSignal<string | null>('group-a');
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
+ result.setTableRootRef(undefined);
- // No setTableRootRef -> effect hits `if (!root ...) return;` -> no
- // listeners -> scroll/resize schedule no rAF.
- window.dispatchEvent(new Event('scroll'));
- window.dispatchEvent(new Event('resize'));
+ // tableRoot stays null -> the reveal effect returns before scheduling.
expect(rafSpy).not.toHaveBeenCalled();
});
- });
-
- // -------------------------------------------------------------------------
- // activeRow guard arms: missing container ref, empty id, querySelector miss,
- // attribute-selector escaping.
- // -------------------------------------------------------------------------
- describe('activeRow guard arms', () => {
- it('returns null when the tableRoot ref has never been set (missing container ref)', () => {
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => 'workload-a' }),
- );
- expect(result.activeRow()).toBeNull();
- });
- it('returns null when setTableRootRef receives undefined (setter `element ?? null` right arm)', () => {
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => 'workload-a' }),
- );
- result.setTableRootRef(undefined);
- expect(result.activeRow()).toBeNull();
- });
+ it('does not attempt a reveal for a whitespace-only focused group id (normalizeSeriesId guard)', () => {
+ const rafSpy = vi.fn((cb: FrameRequestCallback) => {
+ cb(0);
+ return 1;
+ });
+ vi.stubGlobal('requestAnimationFrame', rafSpy);
- it('returns null for null / whitespace-only active ids and the row for a real id (normalizedActiveSeriesId guard)', () => {
const root = document.createElement('div');
- const row = document.createElement('div');
- row.setAttribute('data-summary-series-id', 'workload-a');
- root.appendChild(row);
document.body.appendChild(root);
- const [activeSeriesId, setActiveSeriesId] = createSignal<string | null>(null);
- const { result } = renderHook(() => useSummaryTableFocusBridge({ activeSeriesId }));
+ const [focusedGroupId] = createSignal<string | null>(' ');
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
- expect(result.activeRow()).toBeNull();
- setActiveSeriesId(' ');
- expect(result.activeRow()).toBeNull();
- setActiveSeriesId('workload-a');
- expect(result.activeRow()).toBe(row);
+ expect(rafSpy).not.toHaveBeenCalled();
});
- it('returns null when no descendant carries the matching data attribute (querySelector miss)', () => {
+ it('does not scroll a decoy row when no group row carries the matching id (querySelector miss)', () => {
+ const scrollIntoView = vi.fn();
const root = document.createElement('div');
const decoy = document.createElement('div');
- decoy.setAttribute('data-summary-series-id', 'other');
+ decoy.setAttribute('data-summary-group-id', 'other');
+ Object.defineProperty(decoy, 'getBoundingClientRect', {
+ configurable: true,
+ value: () => buildRect(1200, 40),
+ });
+ Object.defineProperty(decoy, 'scrollIntoView', {
+ configurable: true,
+ value: scrollIntoView,
+ });
root.appendChild(decoy);
document.body.appendChild(root);
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => 'workload-a' }),
- );
+ const [focusedGroupId] = createSignal<string | null>('group-a');
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
- expect(result.activeRow()).toBeNull();
+ expect(scrollIntoView).not.toHaveBeenCalled();
});
- it('escapes backslashes and double quotes in the series id before injecting it into the attribute selector', () => {
+ it('escapes backslashes and double quotes in the group id before injecting it into the attribute selector', () => {
+ const scrollIntoView = vi.fn();
const root = document.createElement('div');
const row = document.createElement('div');
// Literal id containing both a double-quote and a backslash — the exact
// characters escapeAttributeSelectorValue rewrites.
- row.setAttribute('data-summary-series-id', 'id"with\\special');
- root.appendChild(row);
- document.body.appendChild(root);
-
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => 'id"with\\special' }),
- );
- result.setTableRootRef(root);
-
- // If escaping were broken the selector would not match the literal id.
- expect(result.activeRow()).toBe(row);
- });
- });
-
- // -------------------------------------------------------------------------
- // jumpToActiveRow guard arms
- // -------------------------------------------------------------------------
- describe('jumpToActiveRow guard arms', () => {
- it('is a no-op when there is no active series id (normalizedActiveSeriesId falsy -> early return)', () => {
- const revealActiveSeries = vi.fn();
- const rafSpy = vi.fn((cb: FrameRequestCallback) => {
- cb(0);
- return 1;
+ row.setAttribute('data-summary-group-id', 'id"with\\special');
+ Object.defineProperty(row, 'getBoundingClientRect', {
+ configurable: true,
+ value: () => buildRect(1200, 40),
});
- vi.stubGlobal('requestAnimationFrame', rafSpy);
-
- const root = document.createElement('div');
- document.body.appendChild(root);
-
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({
- activeSeriesId: () => null,
- revealActiveSeries,
- }),
- );
- result.setTableRootRef(root);
-
- result.jumpToActiveRow();
-
- expect(revealActiveSeries).not.toHaveBeenCalled();
- expect(rafSpy).not.toHaveBeenCalled();
- });
-
- it('exhausts the 6-frame retry budget without scrolling when the active row never mounts (no matching row)', () => {
- const revealActiveSeries = vi.fn();
- const rafSpy = vi.fn((cb: FrameRequestCallback) => {
- cb(0);
- return 1;
+ Object.defineProperty(row, 'scrollIntoView', {
+ configurable: true,
+ value: scrollIntoView,
});
- vi.stubGlobal('requestAnimationFrame', rafSpy);
-
- const root = document.createElement('div');
+ root.appendChild(row);
document.body.appendChild(root);
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({
- activeSeriesId: () => 'workload-a',
- revealActiveSeries,
- }),
- );
+ const [focusedGroupId] = createSignal<string | null>('id"with\\special');
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
- result.jumpToActiveRow();
-
- // revealActiveSeries fires once before the scroll retry loop.
- expect(revealActiveSeries).toHaveBeenCalledWith('workload-a');
- expect(revealActiveSeries).toHaveBeenCalledTimes(1);
- // attemptScroll(6) recurses once per synchronous rAF until remainingHits
- // 0 -> 6 rAF calls total, then the `remainingFrames <= 0` arm returns.
- expect(rafSpy).toHaveBeenCalledTimes(6);
+ // If escaping were broken the selector would not match the literal id.
+ expect(scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth', block: 'nearest' });
});
});
// -------------------------------------------------------------------------
- // shouldShowJumpToActiveRow — empty summary collections + already-visible row
+ // Active series resolution — page default and transient hover
// -------------------------------------------------------------------------
- describe('shouldShowJumpToActiveRow arms', () => {
- it('is false when no hover/focus/group signal resolves an active series (empty summary collections / page-default state)', () => {
+ describe('active series resolution arms', () => {
+ it('resolves no active series or group when no hover/focus/group signal is set (page-default state)', () => {
const root = document.createElement('div');
document.body.appendChild(root);
const { result } = renderHook(() => useSummaryPageInteractionState({}));
result.setTableRootRef(root);
- // resolveSummaryScopeState returns { kind: 'page', seriesId: null }.
expect(result.activeSeriesId()).toBeNull();
expect(result.activeGroupScope()).toBeNull();
- // Boolean(null) && !isActiveRowVisible() -> false && ... -> false.
- expect(result.shouldShowJumpToActiveRow()).toBe(false);
});
- it('is false when the active row is already inside the viewport (already-focused / visible arm)', () => {
+ it('highlights a hovered off-screen row without moving the page (hover is not a reveal)', () => {
+ const scrollIntoView = vi.fn();
+ const scrollTo = vi.fn();
+ Object.defineProperty(window, 'scrollTo', {
+ configurable: true,
+ value: scrollTo,
+ });
const root = document.createElement('div');
const row = document.createElement('div');
row.setAttribute('data-summary-series-id', 'workload-a');
- // top=200, height=40, innerHeight=800 -> 0 < 200 and 240 < 800 -> visible.
+ // top=1200 > innerHeight(800) -> off-screen.
Object.defineProperty(row, 'getBoundingClientRect', {
configurable: true,
- value: () => buildRect(200, 40),
+ value: () => buildRect(1200, 40),
+ });
+ Object.defineProperty(row, 'scrollIntoView', {
+ configurable: true,
+ value: scrollIntoView,
});
root.appendChild(row);
document.body.appendChild(root);
+ const revealActiveSeries = vi.fn();
const [hoveredSeriesId] = createSignal<string | null>('workload-a');
- const { result } = renderHook(() => useSummaryPageInteractionState({ hoveredSeriesId }));
+ const { result } = renderHook(() =>
+ useSummaryPageInteractionState({ hoveredSeriesId, revealActiveSeries }),
+ );
result.setTableRootRef(root);
expect(result.activeSeriesId()).toBe('workload-a');
- // Boolean('workload-a') && !true -> false.
- expect(result.shouldShowJumpToActiveRow()).toBe(false);
+ expect(revealActiveSeries).not.toHaveBeenCalled();
+ expect(scrollIntoView).not.toHaveBeenCalled();
+ expect(scrollTo).not.toHaveBeenCalled();
});
});
@@ -395,9 +206,7 @@ describe('summaryTableFocus.branchcov0723pm', () => {
document.body.appendChild(root);
const [focusedGroupId] = createSignal<string | null>('group-a');
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => null, focusedGroupId }),
- );
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
// `!isElementVisibleWithinViewport(row) && ...` short-circuits on the
@@ -422,9 +231,7 @@ describe('summaryTableFocus.branchcov0723pm', () => {
document.body.appendChild(root);
const [focusedGroupId] = createSignal<string | null>('group-a');
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => null, focusedGroupId }),
- );
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
expect(scrollIntoView).toHaveBeenCalledWith({
@@ -444,9 +251,7 @@ describe('summaryTableFocus.branchcov0723pm', () => {
document.body.appendChild(root);
const [focusedGroupId] = createSignal<string | null>('group-a');
- const { result } = renderHook(() =>
- useSummaryTableFocusBridge({ activeSeriesId: () => null, focusedGroupId }),
- );
+ const { result } = renderHook(() => useSummaryTableFocusBridge({ focusedGroupId }));
result.setTableRootRef(root);
// Initial rAF + one per decrement: remainingFrames 12->0 = 13 calls.
diff --git a/frontend-modern/src/components/shared/__tests__/summaryTableFocus.test.tsx b/frontend-modern/src/components/shared/__tests__/summaryTableFocus.test.tsx
index a995072b60..1448e4de40 100644
--- a/frontend-modern/src/components/shared/__tests__/summaryTableFocus.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/summaryTableFocus.test.tsx
@@ -1,4 +1,4 @@
-import { renderHook } from '@solidjs/testing-library';
+import { renderHook, waitFor } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { useSummaryPageInteractionState } from '@/components/shared/summaryTableFocus';
@@ -30,8 +30,8 @@ describe('useSummaryPageInteractionState', () => {
vi.unstubAllGlobals();
});
- it('prefers chart hover over row hover and route focus for the active series id', () => {
- const [hoveredSeriesId] = createSignal<string | null>('row-hovered');
+ it('prefers row hover over route focus for the active series id', () => {
+ const [hoveredSeriesId, setHoveredSeriesId] = createSignal<string | null>('row-hovered');
const [focusedSeriesId] = createSignal<string | null>('route-focused');
const { result } = renderHook(() =>
@@ -43,80 +43,72 @@ describe('useSummaryPageInteractionState', () => {
expect(result.activeSeriesId()).toBe('row-hovered');
- result.setChartHoverSync({
- sourceKey: 'cpu',
- seriesId: 'chart-hovered',
- timestamp: 123,
- });
+ setHoveredSeriesId(null);
- expect(result.activeSeriesId()).toBe('chart-hovered');
+ expect(result.activeSeriesId()).toBe('route-focused');
});
- it('shows a jump affordance when the active row is mounted but outside the viewport', () => {
+ it('does not subscribe to window scroll or resize', () => {
+ const addEventListener = vi.spyOn(window, 'addEventListener');
const [hoveredSeriesId] = createSignal<string | null>('workload-a');
- const scrollIntoView = vi.fn();
+ const [focusedSeriesId] = createSignal<string | null>('workload-b');
const root = document.createElement('div');
- const row = document.createElement('div');
- row.setAttribute('data-summary-series-id', 'workload-a');
- Object.defineProperty(row, 'getBoundingClientRect', {
- configurable: true,
- value: () => buildRect(1200),
- });
- Object.defineProperty(row, 'scrollIntoView', {
- configurable: true,
- value: scrollIntoView,
- });
- root.appendChild(row);
document.body.appendChild(root);
const { result } = renderHook(() =>
useSummaryPageInteractionState({
hoveredSeriesId,
+ focusedSeriesId,
}),
);
result.setTableRootRef(root);
- expect(result.shouldShowJumpToActiveRow()).toBe(true);
-
- result.jumpToActiveRow();
-
- expect(scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth', block: 'center' });
+ const subscribed = addEventListener.mock.calls.map(([type]) => type);
+ addEventListener.mockRestore();
+ expect(subscribed).not.toContain('scroll');
+ expect(subscribed).not.toContain('resize');
});
- it('reveals an unmapped row before attempting to scroll to it', () => {
- const [hoveredSeriesId] = createSignal<string | null>('pool-alpha');
- const scrollIntoView = vi.fn();
+ it('reveals a focused row that only mounts once its owning view opens', async () => {
+ const [focusedSeriesId] = createSignal<string | null>('pool-alpha');
+ const scrollTo = vi.fn();
const root = document.createElement('div');
const row = document.createElement('div');
- row.setAttribute('data-summary-series-id', 'pool-alpha');
- Object.defineProperty(row, 'getBoundingClientRect', {
- configurable: true,
- value: () => buildRect(64),
- });
- Object.defineProperty(row, 'scrollIntoView', {
+ const detail = document.createElement('div');
+
+ Object.defineProperty(window, 'scrollTo', {
configurable: true,
- value: scrollIntoView,
+ value: scrollTo,
});
+ vi.stubGlobal('scrollY', 0);
+
+ row.setAttribute('data-summary-series-id', 'pool-alpha');
+ row.getBoundingClientRect = vi.fn(() => buildRect(680, 40));
+ detail.setAttribute('data-inline-detail-for', 'pool-alpha');
+ detail.getBoundingClientRect = vi.fn(() => buildRect(724, 220));
+ document.body.appendChild(root);
+ // The owning view renders the row after the reveal request returns, so the
+ // bridge must pick it up through its mutation observer.
const revealActiveSeries = vi.fn(() => {
- root.appendChild(row);
+ window.setTimeout(() => root.append(row, detail), 0);
});
const { result } = renderHook(() =>
useSummaryPageInteractionState({
- hoveredSeriesId,
+ focusedSeriesId,
revealActiveSeries,
}),
);
result.setTableRootRef(root);
- expect(result.shouldShowJumpToActiveRow()).toBe(true);
-
- result.jumpToActiveRow();
expect(revealActiveSeries).toHaveBeenCalledWith('pool-alpha');
- expect(scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth', block: 'center' });
+ expect(scrollTo).not.toHaveBeenCalled();
+ await waitFor(() => {
+ expect(scrollTo).toHaveBeenCalledWith({ top: 456, behavior: 'smooth' });
+ });
});
it('reveals focused inline detail without hard-centering the row', () => {
diff --git a/frontend-modern/src/components/shared/contextualFocus.ts b/frontend-modern/src/components/shared/contextualFocus.ts
index ad063d931b..8b19aaad6d 100644
--- a/frontend-modern/src/components/shared/contextualFocus.ts
+++ b/frontend-modern/src/components/shared/contextualFocus.ts
@@ -4,12 +4,6 @@ const INLINE_DETAIL_TARGET_TOP_RATIO = 0.28;
const INLINE_DETAIL_MIN_TOP_MARGIN = 72;
const INLINE_DETAIL_MIN_DETAIL_PEEK = 160;
-export interface SummaryChartHoverSync {
- sourceKey: string;
- seriesId: string;
- timestamp: number;
-}
-
const resolveScrollableAncestor = (element: Element | null | undefined): HTMLElement | null => {
let scroller = element instanceof HTMLElement ? element : null;
while (scroller) {
diff --git a/frontend-modern/src/components/shared/summaryCardInteraction.ts b/frontend-modern/src/components/shared/summaryCardInteraction.ts
index bce85138b4..7de92e64d7 100644
--- a/frontend-modern/src/components/shared/summaryCardInteraction.ts
+++ b/frontend-modern/src/components/shared/summaryCardInteraction.ts
@@ -88,7 +88,6 @@ export const resolveSummaryGroupMemberInteractionState = (options: {
};
export const resolveSummaryScopeState = (options: {
- chartHoveredSeriesId?: string | null;
hoveredSeriesId?: string | null;
focusedSeriesId?: string | null;
hoveredGroupScope?: SummarySeriesGroupScope | null;
@@ -102,19 +101,6 @@ export const resolveSummaryScopeState = (options: {
focusedGroupScope: options.focusedGroupScope,
});
- const chartHoveredSeriesId = normalizeSeriesId(options.chartHoveredSeriesId);
- if (
- chartHoveredSeriesId &&
- (!groupScope || isSummarySeriesInGroupScope(groupScope, chartHoveredSeriesId))
- ) {
- return {
- groupScope,
- kind: 'entity',
- seriesId: chartHoveredSeriesId,
- source: 'preview',
- };
- }
-
const hoveredSeriesId = normalizeSeriesId(options.hoveredSeriesId);
if (
hoveredSeriesId &&
@@ -170,7 +156,6 @@ export const resolveSummaryScopeState = (options: {
};
export function resolveSummaryActiveSeriesId(options: {
- chartHoveredSeriesId?: string | null;
hoveredSeriesId?: string | null;
focusedSeriesId?: string | null;
groupScope?: SummarySeriesGroupScope | null;
diff --git a/frontend-modern/src/components/shared/summaryTableFocus.ts b/frontend-modern/src/components/shared/summaryTableFocus.ts
index cf4936f775..68d73100cb 100644
--- a/frontend-modern/src/components/shared/summaryTableFocus.ts
+++ b/frontend-modern/src/components/shared/summaryTableFocus.ts
@@ -1,15 +1,9 @@
import { createEffect, createMemo, createSignal, onCleanup, type Accessor } from 'solid-js';
-import {
- findInlineDetailElement,
- revealInlineDetailInViewport,
- type SummaryChartHoverSync,
-} from './contextualFocus';
+import { findInlineDetailElement, revealInlineDetailInViewport } from './contextualFocus';
import {
resolveSummaryActiveSeriesId,
- resolveSummaryScopeState,
resolveSummaryGroupScope,
type SummarySeriesGroupScope,
- type SummaryScopeState,
} from './summaryCardInteraction';
const normalizeSeriesId = (value: string | null | undefined): string => value?.trim() || '';
@@ -69,7 +63,6 @@ const isElementVisibleWithinViewport = (element: HTMLElement): boolean => {
};
export interface UseSummaryTableFocusBridgeOptions {
- activeSeriesId: Accessor<string | null | undefined>;
focusedSeriesId?: Accessor<string | null | undefined>;
focusedGroupId?: Accessor<string | null | undefined>;
clearPinnedScope?: () => void;
@@ -80,26 +73,9 @@ export interface UseSummaryTableFocusBridgeOptions {
export function useSummaryTableFocusBridge(options: UseSummaryTableFocusBridgeOptions) {
const [tableRoot, setTableRoot] = createSignal<HTMLElement | null>(null);
const [clearSurfaceRoot, setClearSurfaceRoot] = createSignal<HTMLElement | null>(null);
- const [viewportVersion, setViewportVersion] = createSignal(0);
const focusedSeriesId = options.focusedSeriesId ?? (() => null);
const focusedGroupId = options.focusedGroupId ?? (() => null);
- const normalizedActiveSeriesId = createMemo<string | null>(() => {
- const normalized = normalizeSeriesId(options.activeSeriesId());
- return normalized || null;
- });
-
- const activeRow = (): HTMLElement | null => {
- const root = tableRoot();
- const activeSeriesId = normalizedActiveSeriesId();
- if (!root || !activeSeriesId) {
- return null;
- }
- return root.querySelector<HTMLElement>(
- `[data-summary-series-id="${escapeAttributeSelectorValue(activeSeriesId)}"]`,
- );
- };
-
const focusedRow = (): HTMLElement | null => {
const root = tableRoot();
const focusedId = normalizeSeriesId(focusedSeriesId());
@@ -122,19 +98,6 @@ export function useSummaryTableFocusBridge(options: UseSummaryTableFocusBridgeOp
);
};
- const isActiveRowVisible = createMemo<boolean>(() => {
- viewportVersion();
- const row = activeRow();
- if (!row) {
- return false;
- }
- return isElementVisibleWithinViewport(row);
- });
-
- const shouldShowJumpToActiveRow = createMemo<boolean>(() => {
- return Boolean(normalizedActiveSeriesId()) && !isActiveRowVisible();
- });
-
createEffect(() => {
const root = clearSurfaceRoot() ?? tableRoot();
const lookupRoot = tableRoot();
@@ -200,58 +163,6 @@ export function useSummaryTableFocusBridge(options: UseSummaryTableFocusBridgeOp
});
});
- const jumpToActiveRow = () => {
- const activeSeriesId = normalizedActiveSeriesId();
- if (!activeSeriesId) {
- return;
- }
-
- options.revealActiveSeries?.(activeSeriesId);
-
- const attemptScroll = (remainingFrames: number) => {
- const row = activeRow();
- if (row) {
- row.scrollIntoView({ behavior: 'smooth', block: 'center' });
- return;
- }
- if (remainingFrames <= 0 || typeof window === 'undefined') {
- return;
- }
- window.requestAnimationFrame(() => attemptScroll(remainingFrames - 1));
- };
-
- attemptScroll(6);
- };
-
- createEffect(() => {
- const root = tableRoot();
- if (!root || typeof window === 'undefined') {
- return;
- }
-
- let rafId: number | undefined;
- const scheduleViewportRefresh = () => {
- if (rafId !== undefined) {
- return;
- }
- rafId = window.requestAnimationFrame(() => {
- rafId = undefined;
- setViewportVersion((current) => current + 1);
- });
- };
-
- window.addEventListener('scroll', scheduleViewportRefresh, true);
- window.addEventListener('resize', scheduleViewportRefresh);
-
- onCleanup(() => {
- window.removeEventListener('scroll', scheduleViewportRefresh, true);
- window.removeEventListener('resize', scheduleViewportRefresh);
- if (rafId !== undefined) {
- window.cancelAnimationFrame(rafId);
- }
- });
- });
-
createEffect(() => {
const focusedId = normalizeSeriesId(focusedSeriesId());
const root = tableRoot();
@@ -384,13 +295,9 @@ export function useSummaryTableFocusBridge(options: UseSummaryTableFocusBridgeOp
});
return {
- activeRow,
- isActiveRowVisible,
- jumpToActiveRow,
setClearSurfaceRootRef: (element: HTMLElement | undefined) =>
setClearSurfaceRoot(element ?? null),
setTableRootRef: (element: HTMLElement | undefined) => setTableRoot(element ?? null),
- shouldShowJumpToActiveRow,
} as const;
}
@@ -406,7 +313,6 @@ export interface UseSummaryPageInteractionStateOptions {
}
export function useSummaryPageInteractionState(options: UseSummaryPageInteractionStateOptions) {
- const [chartHoverSync, setChartHoverSync] = createSignal<SummaryChartHoverSync | null>(null);
const hoveredSeriesId = options.hoveredSeriesId ?? (() => null);
const focusedSeriesId = options.focusedSeriesId ?? (() => null);
const focusedGroupId = options.focusedGroupId ?? (() => null);
@@ -420,20 +326,8 @@ export function useSummaryPageInteractionState(options: UseSummaryPageInteractio
}),
);
- const activeScopeState = createMemo<SummaryScopeState>(() =>
- resolveSummaryScopeState({
- chartHoveredSeriesId: chartHoverSync()?.seriesId ?? null,
- hoveredSeriesId: hoveredSeriesId(),
- focusedSeriesId: focusedSeriesId(),
- hoveredGroupScope: hoveredGroupScope(),
- focusedGroupScope: focusedGroupScope(),
- groupScope: activeGroupScope(),
- }),
- );
-
const activeSeriesId = createMemo<string | null>(() =>
resolveSummaryActiveSeriesId({
- chartHoveredSeriesId: chartHoverSync()?.seriesId ?? null,
hoveredSeriesId: hoveredSeriesId(),
focusedSeriesId: focusedSeriesId(),
groupScope: activeGroupScope(),
@@ -441,26 +335,17 @@ export function useSummaryPageInteractionState(options: UseSummaryPageInteractio
);
const tableFocus = useSummaryTableFocusBridge({
- activeSeriesId,
clearPinnedScope: options.clearPinnedScope,
focusedSeriesId,
focusedGroupId,
- onEscapeClear: () => {
- setChartHoverSync(null);
- options.onEscapeClear?.();
- },
+ onEscapeClear: options.onEscapeClear,
revealActiveSeries: options.revealActiveSeries,
});
return {
activeGroupScope,
- activeScopeState,
activeSeriesId,
- chartHoverSync,
- jumpToActiveRow: tableFocus.jumpToActiveRow,
setClearSurfaceRootRef: tableFocus.setClearSurfaceRootRef,
- setChartHoverSync,
setTableRootRef: tableFocus.setTableRootRef,
- shouldShowJumpToActiveRow: tableFocus.shouldShowJumpToActiveRow,
} as const;
}