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 Space from toggling summary buttons twice

pulse-triage[bot]21f1dd1e34ce
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 000f291974..8b9bb85592 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,16 @@
## Purpose
+### Summary buttons activate once per Space press
+
+Native summary disclosure and scope buttons retain their existing keydown-owned
+Space action. They cancel the corresponding keyup default as well: mobile
+Chromium can otherwise synthesize a second click and undo the activation.
+Enter, Escape, pointer actions, expanded/pressed semantics and focus ownership
+stay unchanged. Normal-suite `SummaryRowActionButton.test.tsx` checks both button
+kinds and that Enter keyup is not suppressed. Browser proof must exercise actual
+App disclosure Space/Enter, touch and focus at desktop and narrow widths.
+
### TrueNAS protection consumers do not repair malformed instants
The Protection row, completion sorts and inline Started/Completed fields use the
diff --git a/frontend-modern/src/components/shared/SummaryRowActionButton.tsx b/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
index 5c1e518a93..a5cd34be4b 100644
--- a/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
+++ b/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
@@ -73,6 +73,13 @@ export const SummaryRowActionButton: Component<SummaryRowActionButtonProps> = (p
onAction: props.onAction,
onPreviewClear: props.onPreviewClear,
})}
+ onKeyUp={(event) => {
+ // Keydown already owns Space activation. Mobile Chromium can still
+ // issue its native click on keyup, which would undo that action.
+ if (event.key === ' ' || event.key === 'Space' || event.code === 'Space') {
+ event.preventDefault();
+ }
+ }}
>
<Show
when={props.kind === 'scope'}
diff --git a/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx b/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
index ec0423c580..cbd8ce102e 100644
--- a/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
@@ -3,6 +3,53 @@ import { describe, expect, it, vi } from 'vitest';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
describe('SummaryRowActionButton', () => {
+ it.each(['disclosure', 'scope'] as const)(
+ 'prevents a second native Space activation for %s [single-space-activation]',
+ (kind) => {
+ const onAction = vi.fn();
+ render(() =>
+ kind === 'disclosure' ? (
+ <SummaryRowActionButton
+ kind="disclosure"
+ subjectLabel="alpha"
+ expanded={false}
+ hideWhenRowTappableOnMobile={false}
+ onAction={onAction}
+ />
+ ) : (
+ <SummaryRowActionButton
+ kind="scope"
+ subjectLabel="alpha"
+ pressed={false}
+ onAction={onAction}
+ />
+ ),
+ );
+ const button = screen.getByRole('button');
+ fireEvent.keyDown(button, { key: ' ', code: 'Space' });
+ expect(onAction).toHaveBeenCalledTimes(1);
+ const keyup = new KeyboardEvent('keyup', {
+ key: ' ',
+ code: 'Space',
+ bubbles: true,
+ cancelable: true,
+ });
+ expect(button.dispatchEvent(keyup)).toBe(false);
+ expect(keyup.defaultPrevented).toBe(true);
+ expect(onAction).toHaveBeenCalledTimes(1);
+
+ fireEvent.keyDown(button, { key: 'Enter', code: 'Enter' });
+ expect(onAction).toHaveBeenCalledTimes(2);
+ const enterUp = new KeyboardEvent('keyup', {
+ key: 'Enter',
+ code: 'Enter',
+ bubbles: true,
+ cancelable: true,
+ });
+ expect(button.dispatchEvent(enterUp)).toBe(true);
+ },
+ );
+
it('owns disclosure semantics with aria-expanded and aria-controls', () => {
const onAction = vi.fn();
render(() => (