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.

Keep Coverage inspection focus through live row sorting

pulse-triage[bot]506c8d6dc5f3
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 694b272648..77266a1558 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,21 @@
## Purpose
+### Coverage owns focus across native keyed-row movement
+
+Stable keyed row components alone do not preserve native browser focus when a
+posture update changes the sorted DOM order. The existing Coverage consumer
+captures only a target inside its own table before reconciliation and restores
+the same connected target without scrolling if native movement leaves BODY
+focused. Any intervening focus choice cancels that restoration, including a
+choice later blurred to BODY. Removed rows and departed tables are not refocused;
+external search/header controls and existing retirement fallbacks keep ownership.
+This does not change the shared renderer, sort order, row budgets, read cadence,
+posture meaning or access. `ProxmoxCoverageTable.test.tsx` exercises wide/narrow
+VM/LXC moves, same-node detail/disclosure continuity and no-steal/retirement
+controls. Actual Backups desktop/narrow pixels and interactions check poll-driven
+movement against a source-bound parent control.
+
### Coverage keeps provider provenance separate from task state
The existing Coverage drawer uses the shared wrapping detail-section pattern
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 6b4098c097..a464a714a6 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,27 @@
## Purpose
+### Coverage retains owned focus when live posture sorting moves a row
+
+An accepted posture or inventory frame can reorder the same logical workload.
+Keyed row/component retention alone does not retain native focus when DOM nodes
+move. Coverage captures a focus target owned by its table before reconciliation
+and restores that same element without scrolling only if the completed move
+leaves BODY focused and the element and table remain connected. An intervening
+focus choice cancels restoration, even if that choice is subsequently blurred.
+External search/header focus is not reclaimed; removed or departed elements are
+not resurrected. Existing retirement fallbacks still own genuinely removed
+inspection content. Sorting, window budgets, row identity, drawer state,
+posture meanings, read cadence, policy and mutation permissions do not change.
+
+Normal-suite `ProxmoxCoverageTable.test.tsx` covers reordered VM/LXC disclosures
+at wide/narrow widths, retained detail links, external/intervening focus and
+retired/departed targets. Production Backups desktop Chromium and 320px WebKit
+proof binds actual poll-driven quality changes to unchanged same-node controls,
+contrasts the parent native focus loss and checks keyboard/touch use, sorting,
+filter retirement and no focus theft. This is inspection usability, not evidence
+of original workload recovery or a guest/provider operation.
+
### Coverage provider outcomes are not backup job results
Provider evidence identifies the source of each scoped assessment: PBS/PVE
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index d34cdb0c36..63f86758b9 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,27 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### Coverage retains owned focus when live posture sorting moves a row
+
+An accepted posture or inventory frame can reorder the same logical workload.
+Keyed row/component retention alone does not retain native focus when DOM nodes
+move. Coverage captures a focus target owned by its table before reconciliation
+and restores that same element without scrolling only if the completed move
+leaves BODY focused and the element and table remain connected. An intervening
+focus choice cancels restoration, even if that choice is subsequently blurred.
+External search/header focus is not reclaimed; removed or departed elements are
+not resurrected. Existing retirement fallbacks still own genuinely removed
+inspection content. Sorting, window budgets, row identity, drawer state,
+posture meanings, read cadence, policy and mutation permissions do not change.
+
+Normal-suite `ProxmoxCoverageTable.test.tsx` covers reordered VM/LXC disclosures
+at wide/narrow widths, retained detail links, external/intervening focus and
+retired/departed targets. Production Backups desktop Chromium and 320px WebKit
+proof binds actual poll-driven quality changes to unchanged same-node controls,
+contrasts the parent native focus loss and checks keyboard/touch use, sorting,
+filter retirement and no focus theft. This is inspection usability, not evidence
+of original workload recovery or a guest/provider operation.
+
### Coverage provider outcomes are not backup job results
Provider evidence identifies the source of each scoped assessment: PBS/PVE
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index 70a34865a0..ca915e346e 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -540,6 +540,41 @@ export function ProxmoxCoverageTable(props: {
() => setEvidenceLimit(COVERAGE_RESTORE_EVIDENCE_PAGE_SIZE),
),
);
+ let coverageElement: HTMLDivElement | undefined;
+ // Keyed rendering retains the same row nodes, but moving those nodes in the
+ // native DOM can still blur a disclosure or detail link to BODY. Capture only
+ // this table's owned focus before the sorted list reconciles. Never replace
+ // the sort order or refocus a removed row, another route, or a user choice.
+ const renderedRows = createMemo<readonly WorkloadCoverageRow[]>((previous) => {
+ const rows = props.rows;
+ if (
+ rows.length !== previous.length ||
+ rows.some((row, index) => row.key !== previous[index]?.key)
+ ) {
+ const element = coverageElement;
+ const focused = document.activeElement;
+ if (element && focused instanceof HTMLElement && element.contains(focused)) {
+ let redirected = false;
+ const cancel = (event: FocusEvent) => {
+ if (event.target !== focused) redirected = true;
+ };
+ document.addEventListener('focusin', cancel, true);
+ queueMicrotask(() => {
+ document.removeEventListener('focusin', cancel, true);
+ if (
+ !redirected &&
+ element.isConnected &&
+ focused.isConnected &&
+ element.contains(focused) &&
+ document.activeElement === document.body
+ ) {
+ focused.focus({ preventScroll: true });
+ }
+ });
+ }
+ }
+ return rows;
+ }, []);
const observedWidth = useObservedElementWidth();
const layoutMode = createMemo(() => {
const width = props.layoutWidth?.() ?? observedWidth.width();
@@ -579,7 +614,10 @@ export function ProxmoxCoverageTable(props: {
}
>
<div
- ref={observedWidth.setElement}
+ ref={(element) => {
+ coverageElement = element;
+ observedWidth.setElement(element);
+ }}
data-proxmox-backups-table="coverage"
data-proxmox-backups-layout={layoutMode()}
>
@@ -659,7 +697,7 @@ export function ProxmoxCoverageTable(props: {
body={
<>
<PlatformWindowedRows
- items={() => props.rows}
+ items={renderedRows}
keyExtractor={(row) => row.key}
colSpan={columnCount()}
estimatedRowHeight={44}
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
index 0718e44d8a..b2e472155e 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
@@ -1271,7 +1271,6 @@ describe('unknown duration in possible-latest task details', () => {
});
});
-
describe('Coverage owned focus during live reordering', () => {
function mountReordering(width = 1200, type: 'vm' | 'ct' = 'vm') {
const makeRow = (key: string): WorkloadCoverageRow => ({
@@ -1280,6 +1279,7 @@ describe('Coverage owned focus during live reordering', () => {
workload: {
...row.workload,
key,
+ resourceId: key,
type,
typeLabel: type === 'vm' ? 'VM' : 'LXC',
name: key,
@@ -1322,30 +1322,35 @@ describe('Coverage owned focus during live reordering', () => {
[1200, 'ct'],
[320, 'vm'],
[320, 'ct'],
- ] as const)('keeps the same %s px %s disclosure focused after row movement', async (width, type) => {
- const { container, reorder } = mountReordering(width, type);
- const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
- const panel = screen.getByTestId('proxmox-coverage-detail');
- const focus = vi.spyOn(disclosure, 'focus');
- disclosure.focus();
- focus.mockClear();
- reorder();
- await Promise.resolve();
- expect([...container.querySelectorAll('[data-proxmox-backup-row="coverage"]')].map(
- (element) => element.querySelector('button')?.getAttribute('aria-label'),
- )).toEqual([
- expect.stringContaining('zulu'),
- expect.stringContaining('mike'),
- expect.stringContaining('alpha'),
- ]);
- expect(screen.getByRole('button', { name: /Collapse details for alpha/ })).toBe(disclosure);
- expect(screen.getByTestId('proxmox-coverage-detail')).toBe(panel);
- expect(disclosure).toHaveFocus();
- expect(focus).toHaveBeenCalledWith({ preventScroll: true });
- fireEvent.keyDown(disclosure, { key: 'Enter' });
- expect(screen.queryByTestId('proxmox-coverage-detail')).not.toBeInTheDocument();
- expect(disclosure).toHaveFocus();
- });
+ ] as const)(
+ 'keeps the same %s px %s disclosure focused after row movement',
+ async (width, type) => {
+ const { container, reorder } = mountReordering(width, type);
+ const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
+ const panel = screen.getByTestId('proxmox-coverage-detail');
+ const focus = vi.spyOn(disclosure, 'focus');
+ disclosure.focus();
+ focus.mockClear();
+ reorder();
+ await Promise.resolve();
+ expect(
+ [...container.querySelectorAll('[data-proxmox-backup-row="coverage"]')].map((element) =>
+ element.querySelector('button')?.getAttribute('aria-label'),
+ ),
+ ).toEqual([
+ expect.stringContaining('zulu'),
+ expect.stringContaining('mike'),
+ expect.stringContaining('alpha'),
+ ]);
+ expect(screen.getByRole('button', { name: /Collapse details for alpha/ })).toBe(disclosure);
+ expect(screen.getByTestId('proxmox-coverage-detail')).toBe(panel);
+ expect(disclosure).toHaveFocus();
+ expect(focus).toHaveBeenCalledWith({ preventScroll: true });
+ fireEvent.keyDown(disclosure, { key: 'Enter' });
+ expect(screen.queryByTestId('proxmox-coverage-detail')).not.toBeInTheDocument();
+ expect(disclosure).toHaveFocus();
+ },
+ );
it('keeps a connected detail link focused rather than falling back to its disclosure', async () => {
const { reorder } = mountReordering();
@@ -1367,28 +1372,34 @@ describe('Coverage owned focus during live reordering', () => {
expect(outside).toHaveFocus();
});
- it.each([false, true])('does not override an intervening focus choice (then blur: %s)', async (blur) => {
- const { reorder } = mountReordering();
- const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
- disclosure.focus();
- reorder();
- const outside = screen.getByRole('textbox', { name: 'Outside Coverage' });
- outside.focus();
- if (blur) outside.blur();
- await Promise.resolve();
- expect(document.activeElement).toBe(blur ? document.body : outside);
- });
+ it.each([false, true])(
+ 'does not override an intervening focus choice (then blur: %s)',
+ async (blur) => {
+ const { reorder } = mountReordering();
+ const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
+ disclosure.focus();
+ reorder();
+ const outside = screen.getByRole('textbox', { name: 'Outside Coverage' });
+ outside.focus();
+ if (blur) outside.blur();
+ await Promise.resolve();
+ expect(document.activeElement).toBe(blur ? document.body : outside);
+ },
+ );
- it.each(['remove', 'depart'] as const)('does not refocus a retired element after %s', async (kind) => {
- const { reorder, setRows, setMounted, makeRow } = mountReordering();
- const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
- disclosure.focus();
- reorder();
- if (kind === 'depart') setMounted(false);
- else setRows([makeRow('zulu')]);
- const focus = vi.spyOn(disclosure, 'focus');
- await Promise.resolve();
- expect(disclosure).not.toBeInTheDocument();
- expect(focus).not.toHaveBeenCalled();
- });
+ it.each(['remove', 'depart'] as const)(
+ 'does not refocus a retired element after %s',
+ async (kind) => {
+ const { reorder, setRows, setMounted, makeRow } = mountReordering();
+ const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
+ disclosure.focus();
+ reorder();
+ if (kind === 'depart') setMounted(false);
+ else setRows([makeRow('zulu')]);
+ const focus = vi.spyOn(disclosure, 'focus');
+ await Promise.resolve();
+ expect(disclosure).not.toBeInTheDocument();
+ expect(focus).not.toHaveBeenCalled();
+ },
+ );
});