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;