From 7671368fafcab688ac37fd90f9687c942772cba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 22 Aug 2026 03:37:20 +0000 Subject: [PATCH] alt-space opens spotlight from a text field too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The focus guard was still there. I moved the trigger to alt-space, wrote that the guard was no longer load-bearing, and then kept it anyway "as belt-and-braces" — which left the exact bug the move was meant to fix. Focus is usually in the chat composer, so the launcher did not open from the place it is most often wanted. Reported one commit later, by the owner, from a text field. The guard existed because shift-space types a space and eating that keystroke was unacceptable. Alt-space types nothing, so there is nothing to protect. preventDefault on the handler covers the residual case a layout might deliver, which is what the guard was really insuring against. isTyping is deleted rather than left unused: a dead helper carrying a long comment about a decision that has been reversed is worse than no helper, because the comment still reads as current. Co-Authored-By: Claude Opus 5 --- .../Dashboard/Layout/Spotlight/Spotlight.tsx | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/apps/officer-web/Screens/Dashboard/Layout/Spotlight/Spotlight.tsx b/src/apps/officer-web/Screens/Dashboard/Layout/Spotlight/Spotlight.tsx index 81aeaa0f..0912260f 100644 --- a/src/apps/officer-web/Screens/Dashboard/Layout/Spotlight/Spotlight.tsx +++ b/src/apps/officer-web/Screens/Dashboard/Layout/Spotlight/Spotlight.tsx @@ -24,9 +24,10 @@ import { useSpotlightItems, type SpotlightItem } from './useSpotlightItems'; // — which is where focus usually is, the chat composer — so opening Spotlight meant clicking out first. // A launcher you have to prepare for is not a launcher. // -// Alt-space has no meaning inside a text field, so the guard is now belt-and-braces rather than the thing -// holding the feature together. It stays: alt-space reaching a composer as a literal character on some -// layout is cheap to prevent and expensive to discover. +// Alt-space has no meaning inside a text field, so there is NO focus check at all. The guard shift-space +// needed was kept for one commit as "belt-and-braces" and was simply the old bug wearing a new hat: focus +// is usually in the chat composer, so a launcher that stands down there is a launcher that does not open +// when you want it. `preventDefault` on the handler covers the only real risk the guard addressed. // // Nothing else opens it. There is deliberately no second chord — two triggers for one thing means two // things to collide with, and this one moved twice already. @@ -46,21 +47,6 @@ import { useSpotlightItems, type SpotlightItem } from './useSpotlightItems'; cap becomes indistinguishable from a missing feature. */ -/** - * Is the user typing into something? - * - * Kept after the trigger moved to `alt-space`, where it is no longer load-bearing. It was written for - * `shift-space`, which types a space in any text field and so HAD to stand down or it ate a keystroke - * people make by accident all day. Alt-space means nothing in a text field — but a layout that delivers it - * as a literal character exists somewhere, and this is two lines. `isContentEditable` covers the editor - * and any rich input a panel brings with it. - */ -function isTyping(target: EventTarget | null): boolean { - const el = target as HTMLElement | null; - if (!el || !el.tagName) return false; - return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable === true; -} - /** Label with the matched characters picked out, so it is obvious WHY a result is here. */ const Highlighted = ({ label, hits }: { label: string; hits: number[] }) => { if (!hits.length) return <>{label}; @@ -187,7 +173,13 @@ export const Spotlight = () => { const onKey = (ev: KeyboardEvent) => { // `altKey` and `code`, not `key`: alt-space produces a different `key` on several layouts (and // nothing at all on some), while the physical key is `Space` everywhere. - if (ev.altKey && ev.code === 'Space' && !isTyping(ev.target)) { + // + // No focus check. There was one, inherited from shift-space where it was mandatory, and keeping it + // "as belt-and-braces" was wrong in the plainest way: focus is usually IN the chat composer, so the + // guard meant the launcher did not open from the place it is most often wanted. `preventDefault` + // below covers the only thing the guard was protecting against — a layout that would otherwise type + // a character. + if (ev.altKey && ev.code === 'Space') { ev.preventDefault(); setOpen((wasOpen) => !wasOpen); return;