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.

Share bounded backup-table focus restoration

pulse-triage[bot]085e1260e6ec
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 77266a1558..73676074d6 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,19 @@
## Purpose
+### Backup views share bounded owned-focus restoration
+
+Coverage posture sorting and By date regrouping use the same existing backups
+presentation helper for focus lost during a retained native DOM move. It restores
+only the same connected target still inside its table and cancels after any
+intervening focus choice, even if that choice is later blurred. By date's earlier
+restoration did not cancel that latter choice; its normal-suite date-group
+regression now covers it. Genuine retirement still uses the existing surface
+fallback. No sorting, date validity, collection, protection or access rule changes.
+This consolidates overlapping handling rather than widening bundle limits; normal
+Proxmox/shared suites and exact production bundle budgets verify the result.
+Desktop/narrow actual Backups proof includes both views and source-bound pixels.
+
### Coverage owns focus across native keyed-row movement
Stable keyed row components alone do not preserve native browser focus when a
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index a464a714a6..cecdf30310 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,19 @@
## Purpose
+### Backup views share bounded owned-focus restoration
+
+Coverage posture sorting and By date regrouping use the same existing backups
+presentation helper for focus lost during a retained native DOM move. It restores
+only the same connected target still inside its table and cancels after any
+intervening focus choice, even if that choice is later blurred. By date's earlier
+restoration did not cancel that latter choice; its normal-suite date-group
+regression now covers it. Genuine retirement still uses the existing surface
+fallback. No sorting, date validity, collection, protection or access rule changes.
+This consolidates overlapping handling rather than widening bundle limits; normal
+Proxmox/shared suites and exact production bundle budgets verify the result.
+Desktop/narrow actual Backups proof includes both views and source-bound pixels.
+
### Coverage retains owned focus when live posture sorting moves a row
An accepted posture or inventory frame can reorder the same logical workload.
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 63f86758b9..0384f5bae4 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,19 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### Backup views share bounded owned-focus restoration
+
+Coverage posture sorting and By date regrouping use the same existing backups
+presentation helper for focus lost during a retained native DOM move. It restores
+only the same connected target still inside its table and cancels after any
+intervening focus choice, even if that choice is later blurred. By date's earlier
+restoration did not cancel that latter choice; its normal-suite date-group
+regression now covers it. Genuine retirement still uses the existing surface
+fallback. No sorting, date validity, collection, protection or access rule changes.
+This consolidates overlapping handling rather than widening bundle limits; normal
+Proxmox/shared suites and exact production bundle budgets verify the result.
+Desktop/narrow actual Backups proof includes both views and source-bound pixels.
+
### Coverage retains owned focus when live posture sorting moves a row
An accepted posture or inventory frame can reorder the same logical workload.
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index ca915e346e..1f99be8ab8 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -57,6 +57,7 @@ import {
ProxmoxBackupAgeText,
ProxmoxBackupWorkloadTypeBadge,
SortableHead,
+ retainBackupTableFocus,
artifactStateLabel,
getBackupWorkloadPVEConnection,
getBackupWorkloadNodeLabel,
@@ -547,31 +548,8 @@ export function ProxmoxCoverageTable(props: {
// 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 });
- }
- });
- }
+ if (previous.some((row, index) => row.key !== rows[index]?.key)) {
+ retainBackupTableFocus(coverageElement);
}
return rows;
}, []);
diff --git a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
index 5f5301c8a5..36f71bed61 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
@@ -41,6 +41,7 @@ import {
ProxmoxBackupWorkloadTypeBadge,
RowMetricBar,
SortableHead,
+ retainBackupTableFocus,
artifactStateLabel,
getBackupWorkloadPVEConnection,
getBackupWorkloadNodeLabel,
@@ -285,13 +286,7 @@ export function ProxmoxRecoverableTable(props: {
const tableItems = createMemo<RecoverableTableItem[]>(() => {
// Moving a retained keyed row between date groups can blur its control in
// real browsers. Restore only owned, still-mounted focus lost by this move.
- const active = document.activeElement;
- if (active instanceof HTMLElement && table?.contains(active)) {
- queueMicrotask(() => {
- if (active.isConnected && document.activeElement === document.body)
- active.focus({ preventScroll: true });
- });
- }
+ retainBackupTableFocus(table);
if (!showDayGroups()) {
return props.artifacts.map((item) => ({
kind: 'artifact',
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
index b2e472155e..7d4c73a350 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
@@ -1363,6 +1363,19 @@ describe('Coverage owned focus during live reordering', () => {
expect(screen.getByTestId('proxmox-coverage-detail')).toBe(panel);
});
+ it.each([false, true])(
+ 'does not capture deliberate blur when retained rows do not move (append: %s)',
+ async (append) => {
+ const { setRows, makeRow } = mountReordering();
+ const disclosure = screen.getByRole('button', { name: /Collapse details for alpha/ });
+ disclosure.focus();
+ setRows(['alpha', 'mike', 'zulu', ...(append ? ['new'] : [])].map(makeRow));
+ disclosure.blur();
+ await Promise.resolve();
+ expect(document.body).toHaveFocus();
+ },
+ );
+
it('does not reclaim focus already outside Coverage', async () => {
const { reorder } = mountReordering();
const outside = screen.getByRole('textbox', { name: 'Outside Coverage' });
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxRecoverableTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxRecoverableTable.test.tsx
index 41382a3e83..6f98393e61 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxRecoverableTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxRecoverableTable.test.tsx
@@ -292,7 +292,7 @@ describe('restore-point disclosure identity', () => {
});
describe('live date-group focus ownership', () => {
- it.each(['owned', 'moved elsewhere', 'removed'] as const)(
+ it.each(['owned', 'moved elsewhere', 'moved then blurred', 'removed'] as const)(
'restores only retained focus after a row move: %s',
async (focus) => {
const second = {
@@ -336,10 +336,12 @@ describe('live date-group focus ownership', () => {
: [second, unknown, { ...artifact, createdAt: '', createdMs: undefined }],
);
const outside = screen.getByRole('button', { name: 'Outside inspection' });
- if (focus === 'moved elsewhere') outside.focus();
+ if (focus === 'moved elsewhere' || focus === 'moved then blurred') outside.focus();
+ if (focus === 'moved then blurred') outside.blur();
await Promise.resolve();
if (focus === 'owned') expect(toggle).toHaveFocus();
else if (focus === 'moved elsewhere') expect(outside).toHaveFocus();
+ else if (focus === 'moved then blurred') expect(document.body).toHaveFocus();
else {
expect(toggle).not.toBeInTheDocument();
expect(toggle).not.toHaveFocus();
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
index 30b241a7d2..7f76b8551f 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
@@ -34,6 +34,29 @@ import type {
// the orchestrating ProxmoxBackupsTable so each sub-view can import only what
// it renders.
+// A keyed DOM move can blur a retained row control without retiring its owner.
+// Both backup views share the same bounded restoration and no-steal rules.
+export function retainBackupTableFocus(table: HTMLElement | undefined): void {
+ const active = document.activeElement;
+ if (!(active instanceof HTMLElement) || !table?.contains(active)) return;
+ let redirected = false;
+ const cancel = () => {
+ redirected = true;
+ };
+ document.addEventListener('focusin', cancel, true);
+ queueMicrotask(() => {
+ document.removeEventListener('focusin', cancel, true);
+ if (
+ !redirected &&
+ active.isConnected &&
+ table.contains(active) &&
+ document.activeElement === document.body
+ ) {
+ active.focus({ preventScroll: true });
+ }
+ });
+}
+
const PROXMOX_BACKUP_METADATA_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
export const PROXMOX_BACKUP_COLUMN_LABELS = {