Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(web): make insights info tooltips and legend keyboard/screen-reader accessible (#604)

Patel Dhrit6d72aaedb9bf
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
index f85a18df3..7a56823be 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
@@ -584,12 +584,16 @@ export function VisibilityRateTrendChart({ data }: { data: VisibilityRateTrendDa
{shown.map((entity) => (
<li
key={entity.key}
- className="flex cursor-default items-center gap-1.5 text-xs transition-opacity"
+ tabIndex={0}
+ aria-label={entity.name}
+ className="flex cursor-default items-center gap-1.5 rounded-sm text-xs transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
style={{
opacity: hoveredKey !== null && hoveredKey !== entity.key ? 0.35 : 1,
}}
onMouseEnter={() => setHoveredKey(entity.key)}
onMouseLeave={() => setHoveredKey(null)}
+ onFocus={() => setHoveredKey(entity.key)}
+ onBlur={() => setHoveredKey(null)}
>
<span
className="h-2.5 w-2.5 shrink-0 rounded-sm"
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx
index 3d33b26d2..06d276108 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx
@@ -1,6 +1,6 @@
'use client';
-import { useState, useRef, useEffect, useCallback } from 'react';
+import { useState, useRef, useEffect, useCallback, useId } from 'react';
import { Link, useRouter } from '@/i18n/navigation';
import { useSearchParams } from 'next/navigation';
import { createPortal } from 'react-dom';
@@ -170,25 +170,40 @@ function getDateRange(preset: DatePreset, custom: { from: string; to: string })
function InfoTip({ content }: { content: string }) {
const [pos, setPos] = useState<{ x: number; y: number } | null>(null);
const ref = useRef<HTMLSpanElement>(null);
+ const tooltipId = useId();
function show() {
const r = ref.current?.getBoundingClientRect();
if (r) setPos({ x: r.left + r.width / 2, y: r.bottom + 6 });
}
+ function hide() {
+ setPos(null);
+ }
+
return (
<>
<span
ref={ref}
+ tabIndex={0}
+ aria-label="More information"
+ aria-describedby={pos ? tooltipId : undefined}
onMouseEnter={show}
- onMouseLeave={() => setPos(null)}
- className="inline-flex items-center cursor-help"
+ onMouseLeave={hide}
+ onFocus={show}
+ onBlur={hide}
+ onKeyDown={(e) => {
+ if (e.key === 'Escape') hide();
+ }}
+ className="inline-flex items-center cursor-help rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<HelpCircle className="h-3 w-3 text-muted-foreground/60 hover:text-muted-foreground transition-colors" />
</span>
{pos &&
createPortal(
<div
+ id={tooltipId}
+ role="tooltip"
style={{ left: pos.x, top: pos.y, transform: 'translateX(-50%)' }}
className="pointer-events-none fixed z-[9999] w-56 rounded-md border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md"
>