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.

style(web): clear type-to-search formatting gate

pulse-triage[bot]468c2fef5c75
diff --git a/frontend-modern/src/hooks/__tests__/useTypeToSearch.test.ts b/frontend-modern/src/hooks/__tests__/useTypeToSearch.test.ts
index 05d4e0a3c5..f5609b5c4d 100644
--- a/frontend-modern/src/hooks/__tests__/useTypeToSearch.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useTypeToSearch.test.ts
@@ -19,21 +19,27 @@ describe('type-to-search keyboard ownership', () => {
return input;
};
- it.each(['button', 'summary', 'role-button', 'button-child'])('leaves Space to %s', async (kind) => {
- const input = setup();
- const control = document.createElement(kind === 'summary' ? 'summary' : kind === 'role-button' ? 'div' : 'button');
- control.tabIndex = 0;
- if (kind === 'role-button') control.setAttribute('role', 'button');
- document.body.append(control);
- const target = kind === 'button-child' ? control.appendChild(document.createElement('span')) : control;
- control.focus();
- const event = new KeyboardEvent('keydown', { key: ' ', bubbles: true, cancelable: true });
- target.dispatchEvent(event);
- await Promise.resolve();
- expect(event.defaultPrevented).toBe(false);
- expect(document.activeElement).toBe(control);
- expect(input.value).toBe('');
- });
+ it.each(['button', 'summary', 'role-button', 'button-child'])(
+ 'leaves Space to %s',
+ async (kind) => {
+ const input = setup();
+ const control = document.createElement(
+ kind === 'summary' ? 'summary' : kind === 'role-button' ? 'div' : 'button',
+ );
+ control.tabIndex = 0;
+ if (kind === 'role-button') control.setAttribute('role', 'button');
+ document.body.append(control);
+ const target =
+ kind === 'button-child' ? control.appendChild(document.createElement('span')) : control;
+ control.focus();
+ const event = new KeyboardEvent('keydown', { key: ' ', bubbles: true, cancelable: true });
+ target.dispatchEvent(event);
+ await Promise.resolve();
+ expect(event.defaultPrevented).toBe(false);
+ expect(document.activeElement).toBe(control);
+ expect(input.value).toBe('');
+ },
+ );
it('still captures ordinary typing and spaces away from controls', async () => {
const input = setup();
diff --git a/frontend-modern/src/hooks/useTypeToSearch.ts b/frontend-modern/src/hooks/useTypeToSearch.ts
index 3c6c992e52..4e74bffc18 100644
--- a/frontend-modern/src/hooks/useTypeToSearch.ts
+++ b/frontend-modern/src/hooks/useTypeToSearch.ts
@@ -198,10 +198,15 @@ const handleTypeToSearchKeyDown = (event: KeyboardEvent) => {
// Space activates focused buttons/disclosures on keyup. Capturing its
// keydown for search prevents that native action and steals focus.
- if (event.key === ' ' && [event.target, document.activeElement].some(
- (target) => target instanceof HTMLElement &&
- Boolean(target.closest('button, summary, [role="button"]')),
- )) return;
+ if (
+ event.key === ' ' &&
+ [event.target, document.activeElement].some(
+ (target) =>
+ target instanceof HTMLElement &&
+ Boolean(target.closest('button, summary, [role="button"]')),
+ )
+ )
+ return;
if (!isPrintableSearchKey(event)) return;