Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): drop aria-expanded (ARIA tooltip pattern), single visibility source, outside-click gated on visible (#2376)

Adam Eivy1d2fb3ad76ec
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4d5b34508e..c6ebc9d254 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,7 +2,7 @@
## Accessibility
-- **[issue-2376] The CoS Schedule "Global Pause" help is now reachable by keyboard and touch.** Its explanation used to live in a CSS-only `group-hover` popover on a non-focusable info icon, so keyboard and touch users could never read what pausing does before toggling it. It now uses a new reusable, accessible `InfoTooltip` (`client/src/components/ui/InfoTooltip.jsx`): a focusable `<button>` trigger that reveals the help on hover, keyboard focus, OR click/tap, dismisses on Escape or outside click, and links the panel to the trigger via `role="tooltip"` + `aria-describedby` (with `aria-expanded` on the button). The compact inline layout and existing pause toggle are unchanged.
+- **[issue-2376] The CoS Schedule "Global Pause" help is now reachable by keyboard and touch.** Its explanation used to live in a CSS-only `group-hover` popover on a non-focusable info icon, so keyboard and touch users could never read what pausing does before toggling it. It now uses a new reusable, accessible `InfoTooltip` (`client/src/components/ui/InfoTooltip.jsx`): a focusable `<button>` trigger that reveals the help on hover, keyboard focus, OR click/tap, dismisses on Escape or outside click, and links the panel to the trigger via `role="tooltip"` + `aria-describedby` (the ARIA tooltip pattern). The compact inline layout and existing pause toggle are unchanged.
- **The reference-audio waveform is now keyboard-operable and two hand-rolled modals gained real dialog semantics.** The Songs "reference analysis" waveform scrubber was a mouse-only `<div onClick>` (`role="presentation"`) — keyboard and screen-reader users could not seek at all. It is now a proper `role="slider"` with `aria-valuemin/max/now/valuetext`, focusable, and scrubbable with the arrow keys (±1s, ±5s with Shift) plus Home/End (WCAG 2.1.1). Separately, the CyberCity photo-mode "postcard preview" overlay and the Catalog "pick from media gallery" picker were hand-rolled `fixed inset-0` backdrops with no `role="dialog"`, no `aria-modal`, no Escape-to-close, and no focus trap; both now render through the shared `Modal` (focus trap + Esc stack + labelled dialog), with the postcard preview portaled so it escapes the WebGL HUD's stacking/pointer-events context.
diff --git a/client/src/components/ui/InfoTooltip.jsx b/client/src/components/ui/InfoTooltip.jsx
index dc52a9ef72..6b89b98d3e 100644
--- a/client/src/components/ui/InfoTooltip.jsx
+++ b/client/src/components/ui/InfoTooltip.jsx
@@ -9,9 +9,13 @@ import useClickOutside from '../../hooks/useClickOutside';
// users can never reach.
//
// ARIA: the panel carries `role="tooltip"` and is linked to the trigger via
-// `aria-describedby` while visible, so screen readers announce it; the button's
-// `aria-expanded` reflects the click-latched open state. Pass `children` as the
-// help text and `label` as the button's accessible name.
+// `aria-describedby` while visible, so screen readers announce it. There is no
+// `aria-expanded` — this follows the ARIA tooltip pattern (not a disclosure), so
+// exposing an expanded state would misdescribe the widget and could drift out of
+// sync with the hover/focus reveal. `visible` is the single source of truth for
+// whether the panel shows; `pinned` only records that a click latched it open so
+// it survives blur. Pass `children` as the help text and `label` as the button's
+// accessible name.
export default function InfoTooltip({
children,
label = 'More information',
@@ -20,33 +24,35 @@ export default function InfoTooltip({
iconSize = 14,
align = 'center',
}) {
- // `open` is click/tap-latched (survives blur until Escape or outside click);
- // `hovered` is the transient hover/focus reveal. Either makes the panel visible.
- const [open, setOpen] = useState(false);
- const [hovered, setHovered] = useState(false);
+ // `pinned` = a click/tap latched it open (survives blur until Escape / outside
+ // click / another click). `hovering` = the transient hover-or-focus reveal.
+ // The panel is visible when either is true — one derived `visible` flag.
+ const [pinned, setPinned] = useState(false);
+ const [hovering, setHovering] = useState(false);
const wrapRef = useRef(null);
const panelId = useId();
+ const visible = pinned || hovering;
+
const close = useCallback(() => {
- setOpen(false);
- setHovered(false);
+ setPinned(false);
+ setHovering(false);
}, []);
- // Clear BOTH states on outside click: on touch, a tap synthesizes mouseenter
- // (setting `hovered`) alongside the click that latches `open`, and some mobile
- // browsers hold sticky-hover without a matching mouseleave — so clearing only
- // `open` could strand the panel open on the very touch path this targets.
- useClickOutside(wrapRef, open, close);
+ // Drive outside-click dismissal off `visible`, not just `pinned`: on touch a
+ // tap can synthesize a sticky hover (setting `hovering`) that some mobile
+ // browsers never clear with a matching mouseleave, so gating on `pinned` alone
+ // could strand the panel open on the very touch path this component targets.
+ useClickOutside(wrapRef, visible, close);
useEffect(() => {
- if (!open && !hovered) return undefined;
+ if (!visible) return undefined;
const onKey = (e) => {
if (e.key === 'Escape') close();
};
document.addEventListener('keydown', onKey);
return () => document.removeEventListener('keydown', onKey);
- }, [open, hovered, close]);
+ }, [visible, close]);
- const visible = open || hovered;
const alignClass = align === 'start'
? 'left-0'
: align === 'end'
@@ -57,17 +63,16 @@ export default function InfoTooltip({
<div
ref={wrapRef}
className={`relative inline-flex ${className}`}
- onMouseEnter={() => setHovered(true)}
- onMouseLeave={() => setHovered(false)}
+ onMouseEnter={() => setHovering(true)}
+ onMouseLeave={() => setHovering(false)}
>
<button
type="button"
aria-label={label}
- aria-expanded={open}
aria-describedby={visible ? panelId : undefined}
- onClick={() => setOpen((v) => !v)}
- onFocus={() => setHovered(true)}
- onBlur={() => setHovered(false)}
+ onClick={() => setPinned((v) => !v)}
+ onFocus={() => setHovering(true)}
+ onBlur={() => setHovering(false)}
className="inline-flex items-center rounded text-gray-500 transition-colors hover:text-gray-300 focus:text-gray-300 focus:outline-none focus-visible:ring-1 focus-visible:ring-port-accent"
>
<Info size={iconSize} aria-hidden="true" />
diff --git a/client/src/components/ui/InfoTooltip.test.jsx b/client/src/components/ui/InfoTooltip.test.jsx
index 0edf553667..ecb3d7c2dd 100644
--- a/client/src/components/ui/InfoTooltip.test.jsx
+++ b/client/src/components/ui/InfoTooltip.test.jsx
@@ -9,6 +9,8 @@ describe('InfoTooltip', () => {
const btn = screen.getByRole('button', { name: 'What does this do?' });
expect(btn.tagName).toBe('BUTTON');
expect(btn).toHaveAttribute('type', 'button');
+ // Uses the ARIA tooltip pattern, not a disclosure — no aria-expanded.
+ expect(btn).not.toHaveAttribute('aria-expanded');
// Help text is hidden until revealed.
expect(screen.queryByRole('tooltip')).toBeNull();
});
@@ -20,20 +22,30 @@ describe('InfoTooltip', () => {
const panel = screen.getByRole('tooltip');
expect(panel).toHaveTextContent('Keyboard reachable');
expect(btn.getAttribute('aria-describedby')).toBe(panel.getAttribute('id'));
+ // Blur (tabbing away) dismisses the focus-revealed tooltip.
+ fireEvent.blur(btn);
+ expect(screen.queryByRole('tooltip')).toBeNull();
});
- it('toggles (latches) open on click for touch users and reflects aria-expanded', () => {
+ it('latches open on click for touch users and survives blur', () => {
render(<InfoTooltip label="help">Tap reachable</InfoTooltip>);
const btn = screen.getByRole('button', { name: 'help' });
- expect(btn).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(btn);
- expect(btn).toHaveAttribute('aria-expanded', 'true');
expect(screen.getByRole('tooltip')).toHaveTextContent('Tap reachable');
- // Latched open survives blur (unlike a pure hover surface).
+ // Latched open survives blur (unlike a pure hover/focus surface).
fireEvent.blur(btn);
expect(screen.getByRole('tooltip')).toBeTruthy();
});
+ it('closes on a second click (toggle) without stranding the panel visible', () => {
+ render(<InfoTooltip label="help">Toggles</InfoTooltip>);
+ const btn = screen.getByRole('button', { name: 'help' });
+ fireEvent.click(btn);
+ expect(screen.getByRole('tooltip')).toBeTruthy();
+ fireEvent.click(btn);
+ expect(screen.queryByRole('tooltip')).toBeNull();
+ });
+
it('dismisses the latched tooltip on Escape', () => {
render(<InfoTooltip label="help">Dismissable</InfoTooltip>);
const btn = screen.getByRole('button', { name: 'help' });
@@ -41,6 +53,19 @@ describe('InfoTooltip', () => {
expect(screen.getByRole('tooltip')).toBeTruthy();
fireEvent.keyDown(document, { key: 'Escape' });
expect(screen.queryByRole('tooltip')).toBeNull();
- expect(btn).toHaveAttribute('aria-expanded', 'false');
+ });
+
+ it('dismisses on an outside click', () => {
+ render(
+ <div>
+ <InfoTooltip label="help">Outside dismiss</InfoTooltip>
+ <button type="button">elsewhere</button>
+ </div>,
+ );
+ const trigger = screen.getByRole('button', { name: 'help' });
+ fireEvent.click(trigger);
+ expect(screen.getByRole('tooltip')).toBeTruthy();
+ fireEvent.mouseDown(screen.getByRole('button', { name: 'elsewhere' }));
+ expect(screen.queryByRole('tooltip')).toBeNull();
});
});