diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 0000000..36a8913 --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2025-04-30 - Accessible Interactive Widgets with useId +**Learning:** In the `opencitation` Next.js codebase, when building or enhancing accessible React interactive widgets like collapsibles, tabs, or dropdowns, it's critical to use React's `useId` hook to generate unique IDs for ARIA mappings (e.g., `aria-controls` to the content container). This prevents ID collisions across multiple component instances on the same page, ensuring correct screen reader context. +**Action:** Always check `aria-controls` and `id` mappings for dynamic components and standardize on using `useId()` when creating or improving interactive UI patterns in this project. diff --git a/src/components/wiki/wiki-collapsible.tsx b/src/components/wiki/wiki-collapsible.tsx index 5284dd8..72df885 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 (