@adea-ai/ui 0.162.0 → 0.162.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/components/composites/appearance-editor/appearance-choices.d.ts.map +1 -1
  2. package/dist/components/composites/appearance-editor/appearance-choices.js +11 -3
  3. package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
  4. package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
  5. package/dist/components/composites/appearance-editor/appearance-editor.js +1 -4
  6. package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
  7. package/dist/components/composites/appearance-editor/appearance-rows.d.ts +2 -0
  8. package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
  9. package/dist/components/composites/appearance-editor/appearance-rows.js +4 -1
  10. package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
  11. package/dist/components/composites/settings/settings-navigation.d.ts.map +1 -1
  12. package/dist/components/composites/settings/settings-navigation.js +13 -4
  13. package/dist/components/composites/settings/settings-navigation.js.map +1 -1
  14. package/dist/lib/tooltip-focus-gate.d.ts +9 -0
  15. package/dist/lib/tooltip-focus-gate.d.ts.map +1 -1
  16. package/dist/lib/tooltip-focus-gate.js +14 -2
  17. package/dist/lib/tooltip-focus-gate.js.map +1 -1
  18. package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +9 -3
  19. package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +3 -7
  20. package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +8 -1
  21. package/dist/r/src/components/composites/settings/settings-navigation.tsx +33 -6
  22. package/dist/r/src/lib/tooltip-focus-gate.ts +22 -1
  23. package/package.json +1 -1
  24. package/src/components/composites/appearance-editor/appearance-choices.tsx +9 -3
  25. package/src/components/composites/appearance-editor/appearance-editor.tsx +3 -7
  26. package/src/components/composites/appearance-editor/appearance-rows.tsx +8 -1
  27. package/src/components/composites/settings/settings-navigation.tsx +33 -6
  28. package/src/lib/tooltip-focus-gate.ts +22 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip-focus-gate.js","names":[],"sources":["../../src/lib/tooltip-focus-gate.ts"],"sourcesContent":["/*\n * Tooltips open on active hover over the control, or on keyboard focus that\n * follows a Tab key press. They must never open from programmatic focus: the\n * autofocus a dialog or sheet gives its first control, and the focus a closing\n * overlay restores to its opener, both land on buttons that carry tooltips,\n * and the tooltip primitive opens immediately on focus and pins the tooltip\n * until blur. That is the \"tooltip auto-displays when a sheet opens\" report,\n * and the pinned tooltip is the \"tooltip gets stuck and never disappears\"\n * report: the pointer is nowhere near the control, so no pointer leave ever\n * closes it.\n *\n * The trigger listens for the native `focus` event on the trigger element, and\n * composites build tooltips internally (ActionButton renders one from its\n * `tooltip` prop), so the single interception point that covers every tooltip\n * is a capture-phase `focus` listener on `document`. When focus lands without a\n * keyboard-intent signal on a button-like element, the event is stopped before\n * any element listener runs: the tooltip never learns about the focus. Hover\n * opens are untouched (they ride pointer events), and the separate `focusin`\n * event still flows, so dialog focus-cycle tracking, `:focus-visible` styling,\n * and focus restoration all keep working. Focus still lands, only the event\n * is stopped, so `document.activeElement` and scripted `.blur()` behave.\n *\n * The keyboard-intent signal is a Tab key press immediately before the focus,\n * the only key that moves focus natively. Enter and Space open overlays too,\n * so any \"recent key\" window wide enough for those would let an overlay's own\n * autofocus back through; Tab-only keeps autofocus suppressed no matter how\n * the overlay was opened, while normal Tab navigation still announces each\n * control's tooltip (hover descriptions stay reachable from the keyboard).\n *\n * Suppression is scoped to button-like targets (`button`, `a[href]`,\n * `[role=\"button\"]`, `[role=\"link\"]`). Composite widgets that move focus\n * programmatically, menu items, listbox options, grid cells, are other\n * element types whose roving-focus highlighting must keep receiving focus\n * events, and text controls keep their own focus behaviour (select on focus,\n * caret placement).\n *\n * Suppressed focus is real as far as the DOM is concerned (`activeElement`\n * moves; only the event was stopped), and the tooltip interaction model treats\n * a trigger that is `activeElement` as keyboard-held: while a tooltip on it is\n * open, pointer movement away only *requests* a close and the request is\n * refused for as long as the pointer keeps moving. Left alone, a later real\n * hover on that control would open the tip and never let it leave, the\n * residual \"stuck\" case. The gate therefore treats a suppressed focus as a\n * phantom and releases it: the first pointer activity after the focus (a\n * pointer session taking over from a script) blurs the element. Keyboard\n * sessions never release it and never need to, keyboard focus moves by Tab,\n * which is never suppressed, so nothing pins; and the release only runs for\n * elements still holding `activeElement`, so a Tab already taken from the\n * phantom is left alone.\n *\n * Focus that arrives while a pointer button is held belongs to a pointer\n * gesture, not to a tooltip: the pixel resize handle focuses its handle when a\n * drag starts and cancels the drag on blur, so a gesture focus must pass\n * through untouched (no suppression, no phantom, no release). A gesture's own\n * click behaviour already keeps tooltips closed, and the autofocus cases this\n * gate exists for all happen with the pointer up.\n *\n * A tab in a roving-focus tab list is the one button-like element whose\n * programmatic focus is the widget working as designed: a dialog's focus scope\n * and the tab list both put focus on the selected tab, and the tab list scrolls\n * it into view on every focus-in. Releasing that focus would hand it straight\n * back (the scope restores it), so every pointer move would re-suppress,\n * re-release and re-scroll the rail to the top, and a tab below the fold of a\n * large-font or short-window rail could not be clicked. A focus on `role=\"tab\"`\n * is therefore still hidden from the tooltip, so no tooltip opens from it, but\n * it is not tracked as a phantom and the pointer never blurs it.\n *\n * Independently of the gesture window, resize grips render as\n * `<button role=\"separator\">` and carry no tooltip, so they are excluded from\n * the button-like scope entirely (see `isButtonLikeFocusTarget`).\n *\n * The gate is installed by the `Tooltip` root for the lifetime of the first\n * tooltip in a document and removed when the last one unmounts, so every\n * consumer of the primitive, including composites that build their own\n * tooltips, inherits the contract without wiring of its own.\n */\n\n/** How long after a Tab key press a resulting focus event still counts as\n * keyboard navigation. The native focus move follows the key press\n * immediately; the window only has to bridge that dispatch, not a later\n * script-driven focus. */\nexport const TOOLTIP_FOCUS_INTENT_WINDOW_MS = 250\n\n/** Elements a tooltip-bearing control is rendered as. Everything else keeps\n * its native focus behaviour, and so do resize grips (see below). */\nconst BUTTON_LIKE_SELECTOR = 'button, a[href], [role=\"button\"], [role=\"link\"]'\n\n/**\n * Whether a focus event landing on this target could open a tooltip on a\n * button-like control. Accepts any Element (an SVG glyph inside a control,\n * for instance) and duck-types so the decision is testable without a DOM.\n */\nfunction buttonLikeControl(target: unknown): Element | null {\n const element = target as Element | null | undefined\n if (typeof element?.closest !== 'function') return null\n return element.closest(BUTTON_LIKE_SELECTOR)\n}\n\n/**\n * Whether the focus target is a tab of a roving-focus tab list. Its focus is\n * hidden from tooltips like any other programmatic focus, but it is never\n * released by the pointer (see the header).\n */\nexport function isTabFocusTarget(target: unknown): boolean {\n return buttonLikeControl(target)?.getAttribute?.('role') === 'tab'\n}\n\nexport function isButtonLikeFocusTarget(target: unknown): boolean {\n const control = buttonLikeControl(target)\n if (control === null) return false\n // Resize grips render as `<button role=\"separator\">` and focus themselves\n // when a pointer drag starts. They carry no tooltip, and the blur that\n // releases a suppressed focus would end the drag on its first move.\n return control.getAttribute?.('role') !== 'separator'\n}\n\n/**\n * The suppression decision: a button-like focus target hides a tooltip only\n * when no keyboard navigation is in flight. Anything else, a Tab-driven\n * focus, or focus on a non-button element, passes through untouched.\n */\nexport function shouldSuppressTooltipFocus(input: {\n isButtonLike: boolean\n keyboardIntentActive: boolean\n}): boolean {\n return input.isButtonLike && !input.keyboardIntentActive\n}\n\nconst installedDocuments = new WeakSet<Document>()\n\n/**\n * Install the gate on a document. Idempotent per document; returns a disposer\n * that removes the listeners (used by tests and by the tooltip root, which\n * releases the gate when its document's last tooltip unmounts).\n */\nexport function installTooltipFocusGate(doc: Document = document): () => void {\n if (installedDocuments.has(doc)) return () => {}\n\n let lastTabKeyDownAt = Number.NEGATIVE_INFINITY\n /** True between a pointerdown and its pointerup/pointercancel: focus events\n * inside that window belong to a pointer gesture (drag bootstrap, press)\n * and must reach their element untouched. */\n let pointerGestureActive = false\n /** The element holding a suppressed programmatic focus, if it still holds\n * `activeElement`. One slot: a newer suppressed focus replaces an older\n * one, and anything that already lost focus needs no release. */\n let phantomFocusTarget: Element | undefined\n /** The phantom-release `pointermove` listener exists only while a phantom\n * does: a gate that parks a permanent pointer listener on every document\n * with a tooltip in it costs every page a standing listener for a state\n * that is live for a few hundred milliseconds at most. */\n let phantomReleaseAttached = false\n const onKeyDown = (event: KeyboardEvent) => {\n // A later activation key starts a different interaction: its overlay\n // autofocus must not inherit the preceding Tab navigation window.\n lastTabKeyDownAt = event.key === 'Tab' ? Date.now() : Number.NEGATIVE_INFINITY\n }\n const onPointerDown = () => {\n lastTabKeyDownAt = Number.NEGATIVE_INFINITY\n pointerGestureActive = true\n releasePhantomFocus()\n }\n const onPointerGestureEnd = () => {\n pointerGestureActive = false\n }\n const dropPhantom = () => {\n phantomFocusTarget = undefined\n if (phantomReleaseAttached) {\n phantomReleaseAttached = false\n doc.removeEventListener('pointermove', onPointerMove, true)\n }\n }\n const onFocus = (event: FocusEvent) => {\n // Focus that moves on retires the phantom: there is nothing left to\n // release, so the parked pointer listener goes with it.\n if (phantomFocusTarget && event.target !== phantomFocusTarget) dropPhantom()\n if (pointerGestureActive) return\n if (!isButtonLikeFocusTarget(event.target)) return\n const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS\n if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return\n event.stopPropagation()\n if (isTabFocusTarget(event.target)) return\n phantomFocusTarget = event.target as Element\n if (!phantomReleaseAttached) {\n phantomReleaseAttached = true\n doc.addEventListener('pointermove', onPointerMove, true)\n }\n }\n const releasePhantomFocus = () => {\n if (pointerGestureActive) return\n if (!phantomFocusTarget) return\n const phantom = phantomFocusTarget\n dropPhantom()\n if ((doc as Document).activeElement !== phantom) return\n if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()\n }\n const onPointerMove = () => releasePhantomFocus()\n\n doc.addEventListener('keydown', onKeyDown, true)\n doc.addEventListener('focus', onFocus, true)\n doc.addEventListener('pointerdown', onPointerDown, true)\n doc.addEventListener('pointerup', onPointerGestureEnd, true)\n doc.addEventListener('pointercancel', onPointerGestureEnd, true)\n installedDocuments.add(doc)\n return () => {\n doc.removeEventListener('keydown', onKeyDown, true)\n doc.removeEventListener('focus', onFocus, true)\n doc.removeEventListener('pointerdown', onPointerDown, true)\n doc.removeEventListener('pointerup', onPointerGestureEnd, true)\n doc.removeEventListener('pointercancel', onPointerGestureEnd, true)\n doc.removeEventListener('pointermove', onPointerMove, true)\n installedDocuments.delete(doc)\n }\n}\n\n/**\n * Reference-counted install for the tooltip root: the first tooltip in a\n * document acquires the gate, the last one to unmount releases it. The document\n * parameter exists so tests can drive the counter without a global DOM; the\n * production call site guards on the server render before calling.\n */\nconst gateHolders = new WeakMap<Document, number>()\nconst gateDisposers = new WeakMap<Document, () => void>()\n\nexport function acquireTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n gateHolders.set(doc, holders + 1)\n if (holders === 0) gateDisposers.set(doc, installTooltipFocusGate(doc))\n}\n\nexport function releaseTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n if (holders === 0) return\n if (holders === 1) {\n gateHolders.delete(doc)\n gateDisposers.get(doc)?.()\n gateDisposers.delete(doc)\n return\n }\n gateHolders.set(doc, holders - 1)\n}\n"],"mappings":";;;;;AAiFA,IAAa,iCAAiC;;;AAI9C,IAAM,uBAAuB;;;;;;AAO7B,SAAS,kBAAkB,QAAiC;CAC1D,MAAM,UAAU;CAChB,IAAI,OAAO,SAAS,YAAY,YAAY,OAAO;CACnD,OAAO,QAAQ,QAAQ,oBAAoB;AAC7C;;;;;;AAOA,SAAgB,iBAAiB,QAA0B;CACzD,OAAO,kBAAkB,MAAM,CAAC,EAAE,eAAe,MAAM,MAAM;AAC/D;AAEA,SAAgB,wBAAwB,QAA0B;CAChE,MAAM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AO,GAAG;EACxB;CACF;CACA,YAAY,IAAI,KAAK,UAAU,CAAC;AAClC"}
1
+ {"version":3,"file":"tooltip-focus-gate.js","names":[],"sources":["../../src/lib/tooltip-focus-gate.ts"],"sourcesContent":["/*\n * Tooltips open on active hover over the control, or on keyboard focus that\n * follows a Tab key press. They must never open from programmatic focus: the\n * autofocus a dialog or sheet gives its first control, and the focus a closing\n * overlay restores to its opener, both land on buttons that carry tooltips,\n * and the tooltip primitive opens immediately on focus and pins the tooltip\n * until blur. That is the \"tooltip auto-displays when a sheet opens\" report,\n * and the pinned tooltip is the \"tooltip gets stuck and never disappears\"\n * report: the pointer is nowhere near the control, so no pointer leave ever\n * closes it.\n *\n * The trigger listens for the native `focus` event on the trigger element, and\n * composites build tooltips internally (ActionButton renders one from its\n * `tooltip` prop), so the single interception point that covers every tooltip\n * is a capture-phase `focus` listener on `document`. When focus lands without a\n * keyboard-intent signal on a button-like element, the event is stopped before\n * any element listener runs: the tooltip never learns about the focus. Hover\n * opens are untouched (they ride pointer events), and the separate `focusin`\n * event still flows, so dialog focus-cycle tracking, `:focus-visible` styling,\n * and focus restoration all keep working. Focus still lands, only the event\n * is stopped, so `document.activeElement` and scripted `.blur()` behave.\n *\n * The keyboard-intent signal is a Tab key press immediately before the focus,\n * the only key that moves focus natively. Enter and Space open overlays too,\n * so any \"recent key\" window wide enough for those would let an overlay's own\n * autofocus back through; Tab-only keeps autofocus suppressed no matter how\n * the overlay was opened, while normal Tab navigation still announces each\n * control's tooltip (hover descriptions stay reachable from the keyboard).\n *\n * Suppression is scoped to button-like targets (`button`, `a[href]`,\n * `[role=\"button\"]`, `[role=\"link\"]`). Composite widgets that move focus\n * programmatically, menu items, listbox options, grid cells, are other\n * element types whose roving-focus highlighting must keep receiving focus\n * events, and text controls keep their own focus behaviour (select on focus,\n * caret placement).\n *\n * Suppressed focus is real as far as the DOM is concerned (`activeElement`\n * moves; only the event was stopped), and the tooltip interaction model treats\n * a trigger that is `activeElement` as keyboard-held: while a tooltip on it is\n * open, pointer movement away only *requests* a close and the request is\n * refused for as long as the pointer keeps moving. Left alone, a later real\n * hover on that control would open the tip and never let it leave, the\n * residual \"stuck\" case. The gate therefore treats a suppressed focus as a\n * phantom and releases it: the first pointer activity after the focus (a\n * pointer session taking over from a script) blurs the element. Keyboard\n * sessions never release it and never need to, keyboard focus moves by Tab,\n * which is never suppressed, so nothing pins; and the release only runs for\n * elements still holding `activeElement`, so a Tab already taken from the\n * phantom is left alone.\n *\n * Only a pointer that actually travels releases the phantom. WebKit (Safari,\n * WKWebView) dispatches a `pointermove` at the unchanged position whenever a\n * scroll moves content under a resting mouse, and a dialog's restored focus or\n * an autofocus usually scrolls its control into view, so releasing on any\n * move blurred focus no one had touched. That move reports no travel\n * (`movementX` and `movementY` are both 0); a move that reports no movement\n * fields at all still counts as travel (see `pointerMoveTravelled`).\n *\n * Focus that arrives while a pointer button is held belongs to a pointer\n * gesture, not to a tooltip: the pixel resize handle focuses its handle when a\n * drag starts and cancels the drag on blur, so a gesture focus must pass\n * through untouched (no suppression, no phantom, no release). A gesture's own\n * click behaviour already keeps tooltips closed, and the autofocus cases this\n * gate exists for all happen with the pointer up.\n *\n * A tab in a roving-focus tab list is the one button-like element whose\n * programmatic focus is the widget working as designed: a dialog's focus scope\n * and the tab list both put focus on the selected tab, and the tab list scrolls\n * it into view on every focus-in. Releasing that focus would hand it straight\n * back (the scope restores it), so every pointer move would re-suppress,\n * re-release and re-scroll the rail to the top, and a tab below the fold of a\n * large-font or short-window rail could not be clicked. A focus on `role=\"tab\"`\n * is therefore still hidden from the tooltip, so no tooltip opens from it, but\n * it is not tracked as a phantom and the pointer never blurs it.\n *\n * Independently of the gesture window, resize grips render as\n * `<button role=\"separator\">` and carry no tooltip, so they are excluded from\n * the button-like scope entirely (see `isButtonLikeFocusTarget`).\n *\n * The gate is installed by the `Tooltip` root for the lifetime of the first\n * tooltip in a document and removed when the last one unmounts, so every\n * consumer of the primitive, including composites that build their own\n * tooltips, inherits the contract without wiring of its own.\n */\n\n/** How long after a Tab key press a resulting focus event still counts as\n * keyboard navigation. The native focus move follows the key press\n * immediately; the window only has to bridge that dispatch, not a later\n * script-driven focus. */\nexport const TOOLTIP_FOCUS_INTENT_WINDOW_MS = 250\n\n/** Elements a tooltip-bearing control is rendered as. Everything else keeps\n * its native focus behaviour, and so do resize grips (see below). */\nconst BUTTON_LIKE_SELECTOR = 'button, a[href], [role=\"button\"], [role=\"link\"]'\n\n/**\n * Whether a focus event landing on this target could open a tooltip on a\n * button-like control. Accepts any Element (an SVG glyph inside a control,\n * for instance) and duck-types so the decision is testable without a DOM.\n */\nfunction buttonLikeControl(target: unknown): Element | null {\n const element = target as Element | null | undefined\n if (typeof element?.closest !== 'function') return null\n return element.closest(BUTTON_LIKE_SELECTOR)\n}\n\n/**\n * Whether the focus target is a tab of a roving-focus tab list. Its focus is\n * hidden from tooltips like any other programmatic focus, but it is never\n * released by the pointer (see the header).\n */\nexport function isTabFocusTarget(target: unknown): boolean {\n return buttonLikeControl(target)?.getAttribute?.('role') === 'tab'\n}\n\nexport function isButtonLikeFocusTarget(target: unknown): boolean {\n const control = buttonLikeControl(target)\n if (control === null) return false\n // Resize grips render as `<button role=\"separator\">` and focus themselves\n // when a pointer drag starts. They carry no tooltip, and the blur that\n // releases a suppressed focus would end the drag on its first move.\n return control.getAttribute?.('role') !== 'separator'\n}\n\n/**\n * The suppression decision: a button-like focus target hides a tooltip only\n * when no keyboard navigation is in flight. Anything else, a Tab-driven\n * focus, or focus on a non-button element, passes through untouched.\n */\nexport function shouldSuppressTooltipFocus(input: {\n isButtonLike: boolean\n keyboardIntentActive: boolean\n}): boolean {\n return input.isButtonLike && !input.keyboardIntentActive\n}\n\n/**\n * Whether a `pointermove` comes from a pointer that moved, rather than one a\n * browser dispatched at the same position because content scrolled under it.\n * An event without movement fields counts as travel.\n */\nexport function pointerMoveTravelled(event: { movementX?: number; movementY?: number }): boolean {\n const { movementX, movementY } = event\n if (typeof movementX !== 'number' || typeof movementY !== 'number') return true\n return movementX !== 0 || movementY !== 0\n}\n\nconst installedDocuments = new WeakSet<Document>()\n\n/**\n * Install the gate on a document. Idempotent per document; returns a disposer\n * that removes the listeners (used by tests and by the tooltip root, which\n * releases the gate when its document's last tooltip unmounts).\n */\nexport function installTooltipFocusGate(doc: Document = document): () => void {\n if (installedDocuments.has(doc)) return () => {}\n\n let lastTabKeyDownAt = Number.NEGATIVE_INFINITY\n /** True between a pointerdown and its pointerup/pointercancel: focus events\n * inside that window belong to a pointer gesture (drag bootstrap, press)\n * and must reach their element untouched. */\n let pointerGestureActive = false\n /** The element holding a suppressed programmatic focus, if it still holds\n * `activeElement`. One slot: a newer suppressed focus replaces an older\n * one, and anything that already lost focus needs no release. */\n let phantomFocusTarget: Element | undefined\n /** The phantom-release `pointermove` listener exists only while a phantom\n * does: a gate that parks a permanent pointer listener on every document\n * with a tooltip in it costs every page a standing listener for a state\n * that is live for a few hundred milliseconds at most. */\n let phantomReleaseAttached = false\n const onKeyDown = (event: KeyboardEvent) => {\n // A later activation key starts a different interaction: its overlay\n // autofocus must not inherit the preceding Tab navigation window.\n lastTabKeyDownAt = event.key === 'Tab' ? Date.now() : Number.NEGATIVE_INFINITY\n }\n const onPointerDown = () => {\n lastTabKeyDownAt = Number.NEGATIVE_INFINITY\n pointerGestureActive = true\n releasePhantomFocus()\n }\n const onPointerGestureEnd = () => {\n pointerGestureActive = false\n }\n const dropPhantom = () => {\n phantomFocusTarget = undefined\n if (phantomReleaseAttached) {\n phantomReleaseAttached = false\n doc.removeEventListener('pointermove', onPointerMove, true)\n }\n }\n const onFocus = (event: FocusEvent) => {\n // Focus that moves on retires the phantom: there is nothing left to\n // release, so the parked pointer listener goes with it.\n if (phantomFocusTarget && event.target !== phantomFocusTarget) dropPhantom()\n if (pointerGestureActive) return\n if (!isButtonLikeFocusTarget(event.target)) return\n const keyboardIntentActive = Date.now() - lastTabKeyDownAt <= TOOLTIP_FOCUS_INTENT_WINDOW_MS\n if (!shouldSuppressTooltipFocus({ isButtonLike: true, keyboardIntentActive })) return\n event.stopPropagation()\n if (isTabFocusTarget(event.target)) return\n phantomFocusTarget = event.target as Element\n if (!phantomReleaseAttached) {\n phantomReleaseAttached = true\n doc.addEventListener('pointermove', onPointerMove, true)\n }\n }\n const releasePhantomFocus = () => {\n if (pointerGestureActive) return\n if (!phantomFocusTarget) return\n const phantom = phantomFocusTarget\n dropPhantom()\n if ((doc as Document).activeElement !== phantom) return\n if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()\n }\n const onPointerMove = (event: PointerEvent) => {\n if (pointerMoveTravelled(event)) releasePhantomFocus()\n }\n\n doc.addEventListener('keydown', onKeyDown, true)\n doc.addEventListener('focus', onFocus, true)\n doc.addEventListener('pointerdown', onPointerDown, true)\n doc.addEventListener('pointerup', onPointerGestureEnd, true)\n doc.addEventListener('pointercancel', onPointerGestureEnd, true)\n installedDocuments.add(doc)\n return () => {\n doc.removeEventListener('keydown', onKeyDown, true)\n doc.removeEventListener('focus', onFocus, true)\n doc.removeEventListener('pointerdown', onPointerDown, true)\n doc.removeEventListener('pointerup', onPointerGestureEnd, true)\n doc.removeEventListener('pointercancel', onPointerGestureEnd, true)\n doc.removeEventListener('pointermove', onPointerMove, true)\n installedDocuments.delete(doc)\n }\n}\n\n/**\n * Reference-counted install for the tooltip root: the first tooltip in a\n * document acquires the gate, the last one to unmount releases it. The document\n * parameter exists so tests can drive the counter without a global DOM; the\n * production call site guards on the server render before calling.\n */\nconst gateHolders = new WeakMap<Document, number>()\nconst gateDisposers = new WeakMap<Document, () => void>()\n\nexport function acquireTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n gateHolders.set(doc, holders + 1)\n if (holders === 0) gateDisposers.set(doc, installTooltipFocusGate(doc))\n}\n\nexport function releaseTooltipFocusGate(targetDoc?: Document): void {\n if (typeof document === 'undefined' && !targetDoc) return\n const doc = targetDoc ?? document\n const holders = gateHolders.get(doc) ?? 0\n if (holders === 0) return\n if (holders === 1) {\n gateHolders.delete(doc)\n gateDisposers.get(doc)?.()\n gateDisposers.delete(doc)\n return\n }\n gateHolders.set(doc, holders - 1)\n}\n"],"mappings":";;;;;AAyFA,IAAa,iCAAiC;;;AAI9C,IAAM,uBAAuB;;;;;;AAO7B,SAAS,kBAAkB,QAAiC;CAC1D,MAAM,UAAU;CAChB,IAAI,OAAO,SAAS,YAAY,YAAY,OAAO;CACnD,OAAO,QAAQ,QAAQ,oBAAoB;AAC7C;;;;;;AAOA,SAAgB,iBAAiB,QAA0B;CACzD,OAAO,kBAAkB,MAAM,CAAC,EAAE,eAAe,MAAM,MAAM;AAC/D;AAEA,SAAgB,wBAAwB,QAA0B;CAChE,MAAM,UAAU,kBAAkB,MAAM;CACxC,IAAI,YAAY,MAAM,OAAO;CAI7B,OAAO,QAAQ,eAAe,MAAM,MAAM;AAC5C;;;;;;AAOA,SAAgB,2BAA2B,OAG/B;CACV,OAAO,MAAM,gBAAgB,CAAC,MAAM;AACtC;;;;;;AAOA,SAAgB,qBAAqB,OAA4D;CAC/F,MAAM,EAAE,WAAW,cAAc;CACjC,IAAI,OAAO,cAAc,YAAY,OAAO,cAAc,UAAU,OAAO;CAC3E,OAAO,cAAc,KAAK,cAAc;AAC1C;AAEA,IAAM,qCAAqB,IAAI,QAAkB;;;;;;AAOjD,SAAgB,wBAAwB,MAAgB,UAAsB;CAC5E,IAAI,mBAAmB,IAAI,GAAG,GAAG,aAAa,CAAC;CAE/C,IAAI,mBAAmB,OAAO;;;;CAI9B,IAAI,uBAAuB;;;;CAI3B,IAAI;;;;;CAKJ,IAAI,yBAAyB;CAC7B,MAAM,aAAa,UAAyB;EAG1C,mBAAmB,MAAM,QAAQ,QAAQ,KAAK,IAAI,IAAI,OAAO;CAC/D;CACA,MAAM,sBAAsB;EAC1B,mBAAmB,OAAO;EAC1B,uBAAuB;EACvB,oBAAoB;CACtB;CACA,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AI;EAC9D,IAAI,oBAAoB,iBAAiB,qBAAqB,IAAI;EAClE,IAAI,oBAAoB,eAAe,eAAe,IAAI;EAC1D,mBAAmB,OAAO,GAAG;CAC/B;AACF;;;;;;;AAQA,IAAM,8BAAc,IAAI,QAA0B;AAClD,IAAM,gCAAgB,IAAI,QAA8B;AAExD,SAAgB,wBAAwB,WAA4B;CAClE,IAAI,OAAO,aAAa,eAAe,CAAC,WAAW;CACnD,MAAM,MAAM,aAAa;CACzB,MAAM,UAAU,YAAY,IAAI,GAAG,KAAK;CACxC,YAAY,IAAI,KAAK,UAAU,CAAC;CAChC,IAAI,YAAY,GAAG,cAAc,IAAI,KAAK,wBAAwB,GAAG,CAAC;AACxE;AAEA,SAAgB,wBAAwB,WAA4B;CAClE,IAAI,OAAO,aAAa,eAAe,CAAC,WAAW;CACnD,MAAM,MAAM,aAAa;CACzB,MAAM,UAAU,YAAY,IAAI,GAAG,KAAK;CACxC,IAAI,YAAY,GAAG;CACnB,IAAI,YAAY,GAAG;EACjB,YAAY,OAAO,GAAG;EACtB,cAAc,IAAI,GAAG,CAAC,GAAG;EACzB,cAAc,OAAO,GAAG;EACxB;CACF;CACA,YAAY,IAAI,KAAK,UAAU,CAAC;AAClC"}
@@ -46,10 +46,11 @@ const MODES = [
46
46
  { value: 'light', label: 'Light' },
47
47
  { value: 'dark', label: 'Dark' },
48
48
  ] as const
49
+ // Short labels keep the three choices on the Glass row's own line; each says the rest on hover.
49
50
  const SURFACES = [
50
- { value: 'theme', label: 'Theme default' },
51
- { value: 'frosted', label: 'Frosted' },
52
- { value: 'opaque', label: 'Opaque' },
51
+ { value: 'theme', label: 'Theme', hint: "Uses this theme's default surface." },
52
+ { value: 'frosted', label: 'Frosted', hint: 'Theme-colored glass where supported.' },
53
+ { value: 'opaque', label: 'Opaque', hint: 'Solid surfaces for every theme.' },
53
54
  ] as const
54
55
  const MODE_ICONS = { system: Monitor, light: Sun, dark: Moon } as const
55
56
 
@@ -267,6 +268,11 @@ export function GlassChoices(props: AppearanceEditorProps) {
267
268
  <div class="rounded-md focus-within:ring-3 focus-within:ring-ring/50">
268
269
  <SdkRadio
269
270
  value={option.value}
271
+ title={
272
+ option.value === 'theme'
273
+ ? (props.surfaceCapability.themeDefaultDescription ?? option.hint)
274
+ : option.hint
275
+ }
270
276
  disabled={option.value === 'frosted' && !props.surfaceCapability.frosted}
271
277
  class="flex h-7 w-full cursor-pointer items-center rounded-md border px-2 text-xs whitespace-nowrap outline-none data-[checked]:border-primary data-[checked]:ring-1 data-[checked]:ring-primary data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50"
272
278
  >
@@ -102,12 +102,6 @@ export function AppearanceEditor(props: AppearanceEditorProps) {
102
102
  ? `Theme ${offered.label.toLowerCase()} · The theme’s own color.`
103
103
  : 'Theme default · This theme has no such accent.'
104
104
  }
105
- const glassDescription = () =>
106
- props.draft.surface === 'opaque'
107
- ? 'Solid surfaces for every theme.'
108
- : props.draft.surface === 'frosted'
109
- ? 'Theme-colored glass where supported.'
110
- : (props.surfaceCapability.themeDefaultDescription ?? "Uses this theme's default surface.")
111
105
  // One list when no section is asked for; otherwise only that section's rows.
112
106
  const shows = (section: AppearanceEditorTab) =>
113
107
  props.section === undefined || props.section === section
@@ -232,7 +226,9 @@ export function AppearanceEditor(props: AppearanceEditorProps) {
232
226
  the closing slot to them for hosts whose order is palette and
233
227
  surface first, text last. */}
234
228
  <Show when={props.fontSettingsPlacement !== 'end'}>{fontRows()}</Show>
235
- <SettingsRow title="Glass" icon={<PanelsTopLeft />} description={glassDescription()}>
229
+ {/* No subtitle: the three choices fit beside the title, and each explains itself on
230
+ hover. */}
231
+ <SettingsRow title="Glass" icon={<PanelsTopLeft />} compact>
236
232
  <GlassChoices {...props} />
237
233
  </SettingsRow>
238
234
  <Show when={!props.surfaceCapability.frosted && props.surfaceCapability.reason}>
@@ -62,6 +62,8 @@ export function SettingsRow(props: {
62
62
  icon: JSX.Element
63
63
  description?: JSX.Element
64
64
  stacked?: boolean
65
+ /** A short title with no subtitle: the control keeps the title's line at a narrow width. */
66
+ compact?: boolean
65
67
  children: JSX.Element
66
68
  }) {
67
69
  return (
@@ -74,7 +76,12 @@ export function SettingsRow(props: {
74
76
  {/* Reserve readable copy before choosing a side-by-side control row.
75
77
  Wrapping follows the actual host width and enlarged text, rather
76
78
  than a viewport breakpoint that also matches a narrow popover. */}
77
- <div class={cn('flex min-w-0 flex-1 items-center gap-3', { 'basis-48': !props.stacked })}>
79
+ <div
80
+ class={cn('flex min-w-0 flex-1 items-center gap-3', {
81
+ 'basis-48': !props.stacked && !props.compact,
82
+ 'basis-24': !props.stacked && props.compact,
83
+ })}
84
+ >
78
85
  <span
79
86
  class="flex size-9 shrink-0 items-center justify-center rounded-lg border bg-foreground/5 text-muted-foreground [&_svg]:size-4"
80
87
  aria-hidden="true"
@@ -67,8 +67,22 @@ function scrollsOn(value: string): boolean {
67
67
  return value === 'auto' || value === 'scroll'
68
68
  }
69
69
 
70
- /** The nearest-edge delta that brings `[start, end]` inside `[min, max]`. */
71
- function nearestDelta(start: number, end: number, min: number, max: number): number {
70
+ /**
71
+ * The nearest-edge delta that brings `[start, end]` inside `[min, max]`. A range longer than
72
+ * the viewport cannot fit, so it aligns its leading edge (`leadingEnd` for a right-to-left
73
+ * inline axis), where the label starts. Settling on whichever edge overflows instead flips
74
+ * between the two on every reveal: a row-forced strip's full-width rows are wider than its
75
+ * scroller, so each reveal of the same row moved it the other way and the row's position
76
+ * depended on how many reveals had run, leaving it scrolled out of view half the time.
77
+ */
78
+ function nearestDelta(
79
+ start: number,
80
+ end: number,
81
+ min: number,
82
+ max: number,
83
+ leadingEnd = false
84
+ ): number {
85
+ if (end - start > max - min) return leadingEnd ? end - max : start - min
72
86
  if (start < min) return start - min
73
87
  if (end > max) return end - max
74
88
  return 0
@@ -88,12 +102,25 @@ function nearestDelta(start: number, end: number, min: number, max: number): num
88
102
  * which is exactly where the browser would report it after that write.
89
103
  */
90
104
  function revealNearest(row: HTMLElement): void {
91
- const scrollers: { container: HTMLElement; x: boolean; y: boolean; box: DOMRect }[] = []
105
+ const scrollers: {
106
+ container: HTMLElement
107
+ x: boolean
108
+ y: boolean
109
+ rtl: boolean
110
+ box: DOMRect
111
+ }[] = []
92
112
  for (let container = row.parentElement; container; container = container.parentElement) {
93
113
  const style = window.getComputedStyle(container)
94
114
  const x = scrollsOn(style.overflowX)
95
115
  const y = scrollsOn(style.overflowY)
96
- if (x || y) scrollers.push({ container, x, y, box: container.getBoundingClientRect() })
116
+ if (x || y)
117
+ scrollers.push({
118
+ container,
119
+ x,
120
+ y,
121
+ rtl: style.direction === 'rtl',
122
+ box: container.getBoundingClientRect(),
123
+ })
97
124
  }
98
125
  if (scrollers.length === 0) return
99
126
  const rowBox = row.getBoundingClientRect()
@@ -102,8 +129,8 @@ function revealNearest(row: HTMLElement): void {
102
129
  let top = rowBox.top
103
130
  let bottom = rowBox.bottom
104
131
  const writes: { container: HTMLElement; dx: number; dy: number }[] = []
105
- for (const { container, x, y, box } of scrollers) {
106
- const dx = x ? nearestDelta(left, right, box.left, box.right) : 0
132
+ for (const { container, x, y, rtl, box } of scrollers) {
133
+ const dx = x ? nearestDelta(left, right, box.left, box.right, rtl) : 0
107
134
  const dy = y ? nearestDelta(top, bottom, box.top, box.bottom) : 0
108
135
  if (dx === 0 && dy === 0) continue
109
136
  writes.push({ container, dx, dy })
@@ -48,6 +48,14 @@
48
48
  * elements still holding `activeElement`, so a Tab already taken from the
49
49
  * phantom is left alone.
50
50
  *
51
+ * Only a pointer that actually travels releases the phantom. WebKit (Safari,
52
+ * WKWebView) dispatches a `pointermove` at the unchanged position whenever a
53
+ * scroll moves content under a resting mouse, and a dialog's restored focus or
54
+ * an autofocus usually scrolls its control into view, so releasing on any
55
+ * move blurred focus no one had touched. That move reports no travel
56
+ * (`movementX` and `movementY` are both 0); a move that reports no movement
57
+ * fields at all still counts as travel (see `pointerMoveTravelled`).
58
+ *
51
59
  * Focus that arrives while a pointer button is held belongs to a pointer
52
60
  * gesture, not to a tooltip: the pixel resize handle focuses its handle when a
53
61
  * drag starts and cancels the drag on blur, so a gesture focus must pass
@@ -126,6 +134,17 @@ export function shouldSuppressTooltipFocus(input: {
126
134
  return input.isButtonLike && !input.keyboardIntentActive
127
135
  }
128
136
 
137
+ /**
138
+ * Whether a `pointermove` comes from a pointer that moved, rather than one a
139
+ * browser dispatched at the same position because content scrolled under it.
140
+ * An event without movement fields counts as travel.
141
+ */
142
+ export function pointerMoveTravelled(event: { movementX?: number; movementY?: number }): boolean {
143
+ const { movementX, movementY } = event
144
+ if (typeof movementX !== 'number' || typeof movementY !== 'number') return true
145
+ return movementX !== 0 || movementY !== 0
146
+ }
147
+
129
148
  const installedDocuments = new WeakSet<Document>()
130
149
 
131
150
  /**
@@ -194,7 +213,9 @@ export function installTooltipFocusGate(doc: Document = document): () => void {
194
213
  if ((doc as Document).activeElement !== phantom) return
195
214
  if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()
196
215
  }
197
- const onPointerMove = () => releasePhantomFocus()
216
+ const onPointerMove = (event: PointerEvent) => {
217
+ if (pointerMoveTravelled(event)) releasePhantomFocus()
218
+ }
198
219
 
199
220
  doc.addEventListener('keydown', onKeyDown, true)
200
221
  doc.addEventListener('focus', onFocus, true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/ui",
3
- "version": "0.162.0",
3
+ "version": "0.162.2",
4
4
  "description": "The Adea design system: ui-sdk-backed Solid components, semantic OKLCH tokens, and the app-shell layout primitives shared by Adea and Cortana.",
5
5
  "keywords": [
6
6
  "adea",
@@ -46,10 +46,11 @@ const MODES = [
46
46
  { value: 'light', label: 'Light' },
47
47
  { value: 'dark', label: 'Dark' },
48
48
  ] as const
49
+ // Short labels keep the three choices on the Glass row's own line; each says the rest on hover.
49
50
  const SURFACES = [
50
- { value: 'theme', label: 'Theme default' },
51
- { value: 'frosted', label: 'Frosted' },
52
- { value: 'opaque', label: 'Opaque' },
51
+ { value: 'theme', label: 'Theme', hint: "Uses this theme's default surface." },
52
+ { value: 'frosted', label: 'Frosted', hint: 'Theme-colored glass where supported.' },
53
+ { value: 'opaque', label: 'Opaque', hint: 'Solid surfaces for every theme.' },
53
54
  ] as const
54
55
  const MODE_ICONS = { system: Monitor, light: Sun, dark: Moon } as const
55
56
 
@@ -267,6 +268,11 @@ export function GlassChoices(props: AppearanceEditorProps) {
267
268
  <div class="rounded-md focus-within:ring-3 focus-within:ring-ring/50">
268
269
  <SdkRadio
269
270
  value={option.value}
271
+ title={
272
+ option.value === 'theme'
273
+ ? (props.surfaceCapability.themeDefaultDescription ?? option.hint)
274
+ : option.hint
275
+ }
270
276
  disabled={option.value === 'frosted' && !props.surfaceCapability.frosted}
271
277
  class="flex h-7 w-full cursor-pointer items-center rounded-md border px-2 text-xs whitespace-nowrap outline-none data-[checked]:border-primary data-[checked]:ring-1 data-[checked]:ring-primary data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50"
272
278
  >
@@ -102,12 +102,6 @@ export function AppearanceEditor(props: AppearanceEditorProps) {
102
102
  ? `Theme ${offered.label.toLowerCase()} · The theme’s own color.`
103
103
  : 'Theme default · This theme has no such accent.'
104
104
  }
105
- const glassDescription = () =>
106
- props.draft.surface === 'opaque'
107
- ? 'Solid surfaces for every theme.'
108
- : props.draft.surface === 'frosted'
109
- ? 'Theme-colored glass where supported.'
110
- : (props.surfaceCapability.themeDefaultDescription ?? "Uses this theme's default surface.")
111
105
  // One list when no section is asked for; otherwise only that section's rows.
112
106
  const shows = (section: AppearanceEditorTab) =>
113
107
  props.section === undefined || props.section === section
@@ -232,7 +226,9 @@ export function AppearanceEditor(props: AppearanceEditorProps) {
232
226
  the closing slot to them for hosts whose order is palette and
233
227
  surface first, text last. */}
234
228
  <Show when={props.fontSettingsPlacement !== 'end'}>{fontRows()}</Show>
235
- <SettingsRow title="Glass" icon={<PanelsTopLeft />} description={glassDescription()}>
229
+ {/* No subtitle: the three choices fit beside the title, and each explains itself on
230
+ hover. */}
231
+ <SettingsRow title="Glass" icon={<PanelsTopLeft />} compact>
236
232
  <GlassChoices {...props} />
237
233
  </SettingsRow>
238
234
  <Show when={!props.surfaceCapability.frosted && props.surfaceCapability.reason}>
@@ -62,6 +62,8 @@ export function SettingsRow(props: {
62
62
  icon: JSX.Element
63
63
  description?: JSX.Element
64
64
  stacked?: boolean
65
+ /** A short title with no subtitle: the control keeps the title's line at a narrow width. */
66
+ compact?: boolean
65
67
  children: JSX.Element
66
68
  }) {
67
69
  return (
@@ -74,7 +76,12 @@ export function SettingsRow(props: {
74
76
  {/* Reserve readable copy before choosing a side-by-side control row.
75
77
  Wrapping follows the actual host width and enlarged text, rather
76
78
  than a viewport breakpoint that also matches a narrow popover. */}
77
- <div class={cn('flex min-w-0 flex-1 items-center gap-3', { 'basis-48': !props.stacked })}>
79
+ <div
80
+ class={cn('flex min-w-0 flex-1 items-center gap-3', {
81
+ 'basis-48': !props.stacked && !props.compact,
82
+ 'basis-24': !props.stacked && props.compact,
83
+ })}
84
+ >
78
85
  <span
79
86
  class="flex size-9 shrink-0 items-center justify-center rounded-lg border bg-foreground/5 text-muted-foreground [&_svg]:size-4"
80
87
  aria-hidden="true"
@@ -67,8 +67,22 @@ function scrollsOn(value: string): boolean {
67
67
  return value === 'auto' || value === 'scroll'
68
68
  }
69
69
 
70
- /** The nearest-edge delta that brings `[start, end]` inside `[min, max]`. */
71
- function nearestDelta(start: number, end: number, min: number, max: number): number {
70
+ /**
71
+ * The nearest-edge delta that brings `[start, end]` inside `[min, max]`. A range longer than
72
+ * the viewport cannot fit, so it aligns its leading edge (`leadingEnd` for a right-to-left
73
+ * inline axis), where the label starts. Settling on whichever edge overflows instead flips
74
+ * between the two on every reveal: a row-forced strip's full-width rows are wider than its
75
+ * scroller, so each reveal of the same row moved it the other way and the row's position
76
+ * depended on how many reveals had run, leaving it scrolled out of view half the time.
77
+ */
78
+ function nearestDelta(
79
+ start: number,
80
+ end: number,
81
+ min: number,
82
+ max: number,
83
+ leadingEnd = false
84
+ ): number {
85
+ if (end - start > max - min) return leadingEnd ? end - max : start - min
72
86
  if (start < min) return start - min
73
87
  if (end > max) return end - max
74
88
  return 0
@@ -88,12 +102,25 @@ function nearestDelta(start: number, end: number, min: number, max: number): num
88
102
  * which is exactly where the browser would report it after that write.
89
103
  */
90
104
  function revealNearest(row: HTMLElement): void {
91
- const scrollers: { container: HTMLElement; x: boolean; y: boolean; box: DOMRect }[] = []
105
+ const scrollers: {
106
+ container: HTMLElement
107
+ x: boolean
108
+ y: boolean
109
+ rtl: boolean
110
+ box: DOMRect
111
+ }[] = []
92
112
  for (let container = row.parentElement; container; container = container.parentElement) {
93
113
  const style = window.getComputedStyle(container)
94
114
  const x = scrollsOn(style.overflowX)
95
115
  const y = scrollsOn(style.overflowY)
96
- if (x || y) scrollers.push({ container, x, y, box: container.getBoundingClientRect() })
116
+ if (x || y)
117
+ scrollers.push({
118
+ container,
119
+ x,
120
+ y,
121
+ rtl: style.direction === 'rtl',
122
+ box: container.getBoundingClientRect(),
123
+ })
97
124
  }
98
125
  if (scrollers.length === 0) return
99
126
  const rowBox = row.getBoundingClientRect()
@@ -102,8 +129,8 @@ function revealNearest(row: HTMLElement): void {
102
129
  let top = rowBox.top
103
130
  let bottom = rowBox.bottom
104
131
  const writes: { container: HTMLElement; dx: number; dy: number }[] = []
105
- for (const { container, x, y, box } of scrollers) {
106
- const dx = x ? nearestDelta(left, right, box.left, box.right) : 0
132
+ for (const { container, x, y, rtl, box } of scrollers) {
133
+ const dx = x ? nearestDelta(left, right, box.left, box.right, rtl) : 0
107
134
  const dy = y ? nearestDelta(top, bottom, box.top, box.bottom) : 0
108
135
  if (dx === 0 && dy === 0) continue
109
136
  writes.push({ container, dx, dy })
@@ -48,6 +48,14 @@
48
48
  * elements still holding `activeElement`, so a Tab already taken from the
49
49
  * phantom is left alone.
50
50
  *
51
+ * Only a pointer that actually travels releases the phantom. WebKit (Safari,
52
+ * WKWebView) dispatches a `pointermove` at the unchanged position whenever a
53
+ * scroll moves content under a resting mouse, and a dialog's restored focus or
54
+ * an autofocus usually scrolls its control into view, so releasing on any
55
+ * move blurred focus no one had touched. That move reports no travel
56
+ * (`movementX` and `movementY` are both 0); a move that reports no movement
57
+ * fields at all still counts as travel (see `pointerMoveTravelled`).
58
+ *
51
59
  * Focus that arrives while a pointer button is held belongs to a pointer
52
60
  * gesture, not to a tooltip: the pixel resize handle focuses its handle when a
53
61
  * drag starts and cancels the drag on blur, so a gesture focus must pass
@@ -126,6 +134,17 @@ export function shouldSuppressTooltipFocus(input: {
126
134
  return input.isButtonLike && !input.keyboardIntentActive
127
135
  }
128
136
 
137
+ /**
138
+ * Whether a `pointermove` comes from a pointer that moved, rather than one a
139
+ * browser dispatched at the same position because content scrolled under it.
140
+ * An event without movement fields counts as travel.
141
+ */
142
+ export function pointerMoveTravelled(event: { movementX?: number; movementY?: number }): boolean {
143
+ const { movementX, movementY } = event
144
+ if (typeof movementX !== 'number' || typeof movementY !== 'number') return true
145
+ return movementX !== 0 || movementY !== 0
146
+ }
147
+
129
148
  const installedDocuments = new WeakSet<Document>()
130
149
 
131
150
  /**
@@ -194,7 +213,9 @@ export function installTooltipFocusGate(doc: Document = document): () => void {
194
213
  if ((doc as Document).activeElement !== phantom) return
195
214
  if (typeof (phantom as HTMLElement).blur === 'function') (phantom as HTMLElement).blur()
196
215
  }
197
- const onPointerMove = () => releasePhantomFocus()
216
+ const onPointerMove = (event: PointerEvent) => {
217
+ if (pointerMoveTravelled(event)) releasePhantomFocus()
218
+ }
198
219
 
199
220
  doc.addEventListener('keydown', onKeyDown, true)
200
221
  doc.addEventListener('focus', onFocus, true)