diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 0000000..2f4ae0b --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2025-04-29 - Missing ID Mapping in Interactive Widgets +**Learning:** Custom interactive widgets (like collapsibles and tabs) across the codebase often miss `aria-controls` mapping because generating unique IDs manually is cumbersome. +**Action:** Use React's `useId` hook consistently in these components to generate unique IDs and map `aria-controls` to the content containers and `aria-expanded` attributes on toggle buttons, improving screen reader context. diff --git a/src/components/wiki/wiki-collapsible.tsx b/src/components/wiki/wiki-collapsible.tsx index 5284dd8..f507721 100644 --- a/src/components/wiki/wiki-collapsible.tsx +++ b/src/components/wiki/wiki-collapsible.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useId } from "react"; interface WikiCollapsibleProps { title: string; @@ -14,6 +14,7 @@ export function WikiCollapsible({ defaultOpen = true, }: WikiCollapsibleProps) { const [isOpen, setIsOpen] = useState(defaultOpen); + const contentId = useId(); return (
@@ -22,11 +23,14 @@ export function WikiCollapsible({
- {isOpen &&
{children}
} + {isOpen &&
{children}
} ); }