From 2552a80ca85554b32d8dab7f79c9a1c9115742cc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 10:27:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20[UX=20improvement]=20?= =?UTF-8?q?Add=20proper=20ARIA=20controls=20and=20dynamic=20ID=20to=20PPP?= =?UTF-8?q?=20savings=20expand=20toggle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added useId to generate a dynamic contentId and added aria-controls to the expand/collapse toggle. Added id={contentId} to both branch elements of the conditional rendering. This ensures screen reader association remains unbroken for the expanding content section. Adding aria-controls explicitly links the trigger button to the dynamically rendered content panels. Using useId() ensures unique IDs if the component is reused. Co-authored-by: brycejohnson1417 <257422776+brycejohnson1417@users.noreply.github.com> --- .Jules/palette.md | 3 +++ components/accounts/ppp-savings-panel.tsx | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .Jules/palette.md diff --git a/.Jules/palette.md b/.Jules/palette.md new file mode 100644 index 0000000..20e89bd --- /dev/null +++ b/.Jules/palette.md @@ -0,0 +1,3 @@ +## 2024-07-07 - Add proper ARIA controls to conditional accordion content +**Learning:** When building an accordion where the content block is conditionally rendered (e.g. `collapsed ? : `), attaching `id={contentId}` to only one branch or hardcoding string IDs can break screen reader association or cause ID collisions. Using `useId()` to generate the ID and applying it to both conditional branches ensures an unbroken `aria-controls` relationship in all states. +**Action:** Applied `useId()` and `aria-controls` to the PPP savings panel toggle, attaching the ID to both the collapsed summary and expanded full view branches. diff --git a/components/accounts/ppp-savings-panel.tsx b/components/accounts/ppp-savings-panel.tsx index e6d961b..75146ac 100644 --- a/components/accounts/ppp-savings-panel.tsx +++ b/components/accounts/ppp-savings-panel.tsx @@ -1,6 +1,6 @@ "use client"; -import { useMemo, useState } from "react"; +import { useId, useMemo, useState } from "react"; import DOMPurify from "isomorphic-dompurify"; import { Calculator, ChevronDown, ChevronUp, Copy, Download, Loader2, Mail } from "lucide-react"; import type { PppSavingsReport } from "@/lib/application/runtime/ppp-savings-service"; @@ -34,6 +34,7 @@ export function PppSavingsPanel({ orgSlug, accountId }: PppSavingsPanelProps) { const [error, setError] = useState(null); const [copied, setCopied] = useState(false); const [collapsed, setCollapsed] = useState(false); + const contentId = useId(); const mailtoHref = useMemo(() => { if (!report?.recipientEmail || !draft) { @@ -102,6 +103,7 @@ export function PppSavingsPanel({ orgSlug, accountId }: PppSavingsPanelProps) { type="button" onClick={() => setCollapsed((value) => !value)} aria-expanded={!collapsed} + aria-controls={contentId} className="inline-flex items-center justify-center gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-elevated)] px-4 py-3 text-sm font-semibold text-[var(--text-secondary)] transition hover:border-[var(--border-strong)] hover:text-[var(--text-primary)]" > {collapsed ? : } @@ -123,7 +125,7 @@ export function PppSavingsPanel({ orgSlug, accountId }: PppSavingsPanelProps) { {error ? {error} : null} {report && collapsed ? ( - + {formatMoney(report.totalSavings)} savings @@ -146,7 +148,7 @@ export function PppSavingsPanel({ orgSlug, accountId }: PppSavingsPanelProps) { ) : null} ) : report ? ( - +