Skip to content

Commit 2557cf5

Browse files
fix: resolve moderate/serious accessibility audit issues
2 parents f276b1d + 9319874 commit 2557cf5

16 files changed

Lines changed: 119 additions & 53 deletions

File tree

src/app/(registry)/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export default function Home() {
345345
alias:
346346
</p>
347347
<CodeBlock
348+
ariaLabel="Test setup App.jsx example"
348349
code={`import { Button } from "@/components/ui/button"
349350
350351
export default function MyComponent() {

src/app/(registry)/rtl/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export default function RTLPage() {
242242
</p>
243243
<CodeBlock
244244
code={UseDirectionCode}
245+
ariaLabel="useDirection hook code"
245246
lang="tsx"
246247
showLineNumbers={true}
247248
className="bg-body-bg border"
@@ -310,6 +311,7 @@ export default function RTLPage() {
310311
<div>
311312
<h3 className="font-semibold text-xl mb-2">Basic Usage</h3>
312313
<CodeBlock
314+
ariaLabel="Basic RTL DirectionProvider example"
313315
code={`import { Direction } from "radix-ui";
314316
315317
export default function App() {
@@ -330,6 +332,7 @@ export default function App() {
330332
Using the Hook in Components
331333
</h3>
332334
<CodeBlock
335+
ariaLabel="Sidebar RTL useDirection example"
333336
code={`import { Direction } from "radix-ui";
334337
import { cn } from "@/lib/utils";
335338
@@ -361,6 +364,7 @@ export function Sidebar() {
361364
Code blocks should always remain LTR for readability:
362365
</p>
363366
<CodeBlock
367+
ariaLabel="Keep code blocks LTR example"
364368
code={`export function CodeBlock({ code }: { code: string }) {
365369
return (
366370
<div dir="ltr">

src/app/content/ui/combobox/combobox-multiple.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export default function ComboboxMultipleDemo() {
3737
{(values: readonly string[]) => (
3838
<React.Fragment>
3939
{values.map((value: string) => (
40-
<ComboboxChip key={value} aria-label="Remove chip">
41-
{value}
42-
</ComboboxChip>
40+
<ComboboxChip key={value}>{value}</ComboboxChip>
4341
))}
4442
<ComboboxChipsInput aria-label="Combobox chips input" />
4543
</React.Fragment>

src/app/content/ui/popover/popover.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,37 @@ export default function PopoverDemo() {
2424
<div className="grid gap-2">
2525
<div className="grid grid-cols-3 items-center gap-4">
2626
<Label htmlFor="width">Width</Label>
27-
<Input id="width" defaultValue="100%" className="col-span-2" />
27+
<Input
28+
id="width"
29+
defaultValue="100%"
30+
autoComplete="off"
31+
className="col-span-2"
32+
/>
2833
</div>
2934
<div className="grid grid-cols-3 items-center gap-4">
3035
<Label htmlFor="maxWidth">Max. width</Label>
3136
<Input
3237
id="maxWidth"
3338
defaultValue="300px"
39+
autoComplete="off"
3440
className="col-span-2"
3541
/>
3642
</div>
3743
<div className="grid grid-cols-3 items-center gap-4">
3844
<Label htmlFor="height">Height</Label>
39-
<Input id="height" defaultValue="25px" className="col-span-2" />
45+
<Input
46+
id="height"
47+
defaultValue="25px"
48+
autoComplete="off"
49+
className="col-span-2"
50+
/>
4051
</div>
4152
<div className="grid grid-cols-3 items-center gap-4">
4253
<Label htmlFor="maxHeight">Max. height</Label>
4354
<Input
4455
id="maxHeight"
4556
defaultValue="none"
57+
autoComplete="off"
4658
className="col-span-2"
4759
/>
4860
</div>

src/components/bloks/collaboration.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,35 +136,29 @@ function UserListItem({
136136
onAdd?: () => void;
137137
onRemove?: () => void;
138138
}) {
139-
const [isHovered, setIsHovered] = useState(false);
140-
141139
return (
142-
<div
143-
className="flex items-center justify-between py-2 px-1 rounded-md hover:bg-neutral-bg transition-colors"
144-
onMouseEnter={() => setIsHovered(true)}
145-
onMouseLeave={() => setIsHovered(false)}
146-
>
147-
<div className="flex items-center gap-3">
140+
<div className="group flex min-w-0 items-center justify-between gap-2 py-2 px-1 rounded-md hover:bg-neutral-bg transition-colors">
141+
<div className="flex min-w-0 flex-1 items-center gap-3">
148142
<Avatar className="size-8">
149143
<AvatarImage src={user.avatarUrl} alt={user.name} />
150144
<AvatarFallback className="text-xs bg-muted">
151145
{getInitials(user.name)}
152146
</AvatarFallback>
153147
</Avatar>
154-
<span className="text-sm font-medium">
148+
<span className="truncate text-sm font-medium">
155149
{user.name}
156150
{isCurrentUser && (
157151
<span className="text-muted-foreground"> (You)</span>
158152
)}
159153
</span>
160154
</div>
161-
{isAdded && isHovered && onRemove && (
155+
{isAdded && onRemove && (
162156
<Button
163157
variant="link"
164158
size="xs"
165159
colorScheme="primary"
166160
onClick={onRemove}
167-
className="h-auto py-0.5 px-2 no-underline hover:no-underline font-bold"
161+
className="h-auto py-0.5 px-2 no-underline hover:no-underline font-bold opacity-0 group-hover:opacity-100 focus-visible:opacity-100"
168162
>
169163
Remove
170164
</Button>
@@ -294,6 +288,7 @@ export function Collaboration<T extends User = User>({
294288
<PopoverContent
295289
align="end"
296290
sideOffset={8}
291+
aria-label={title}
297292
className="w-[368px] p-0 border-0 bg-transparent shadow-none"
298293
>
299294
{/* Users Panel */}
@@ -313,7 +308,7 @@ export function Collaboration<T extends User = User>({
313308
{emptyStateMessage}
314309
</div>
315310
) : (
316-
<div className="space-y-1 max-h-48 overflow-y-auto">
311+
<div className="max-h-48 space-y-1 overflow-y-auto overflow-x-hidden">
317312
{users.map((user) => {
318313
const userId = getUserId(user as T);
319314
const currentUserId = currentUser
@@ -360,6 +355,7 @@ export function Collaboration<T extends User = User>({
360355
align="center"
361356
sideOffset={-8}
362357
alignOffset={26}
358+
aria-label="Add users"
363359
className="w-[420px] p-0 border-0 bg-transparent shadow-none"
364360
>
365361
{/* Add Users Panel */}
@@ -412,7 +408,7 @@ export function Collaboration<T extends User = User>({
412408
</SearchInput>
413409
</div>
414410

415-
<div className="space-y-1 max-h-48 overflow-y-auto">
411+
<div className="max-h-48 space-y-1 overflow-y-auto overflow-x-hidden">
416412
{isSearching && (
417413
<div className="text-sm text-muted-foreground py-4 text-center">
418414
Searching...

src/components/code-block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function CodeBlock({
162162
return (
163163
<div
164164
dir="ltr"
165-
role="region"
165+
role={ariaLabel ? "region" : undefined}
166166
aria-label={ariaLabel}
167167
className={cn(
168168
"relative rounded-md bg-muted max-h-[400px] overflow-auto",

src/components/docsite/component-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const DemoWrapper = dynamic(() => import("@/components/demo-wrapper"), {
1111

1212
export function ComponentCard({ component }: ComponentCardProps) {
1313
return (
14-
<section>
14+
<section aria-label="Component preview">
1515
<div id="starting-kit">
1616
<div className="w-full min-w-0 overflow-x-hidden">
1717
<DemoWrapper name={component.name} />

src/components/layout/topbar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,10 @@ export default function TopBar() {
522522

523523
{/* Top navigation */}
524524
<nav aria-label="Top navigation">
525-
<NavigationMenu className="hidden lg:flex">
525+
<NavigationMenu
526+
className="hidden lg:flex"
527+
aria-label="Site navigation"
528+
>
526529
<NavigationMenuList className="flex gap-3">
527530
{navItems.map((item) => {
528531
const normalizedPathname = pathname.replace(/\/$/, "") || "/";

src/components/ui/accordion.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,31 @@ function AccordionTrigger({
3535
actions?: React.ReactNode;
3636
}) {
3737
return (
38-
<AccordionPrimitive.Header className="flex items-center hover:bg-blackAlpha-50 transition-colors w-full min-w-0">
39-
<AccordionPrimitive.Trigger
40-
data-slot="accordion-trigger"
41-
className={cn(
42-
"focus-visible:border-ring focus-visible:ring-ring/50 text-md font-regular flex flex-1 cursor-pointer items-center justify-between gap-4 px-2 py-4 text-left transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180 min-w-0",
43-
className,
44-
)}
45-
{...props}
46-
>
47-
{children}
48-
<Icon
49-
path={mdiChevronDown}
50-
className="transition-transform duration-200 size-6 shrink-0"
51-
/>
52-
</AccordionPrimitive.Trigger>
53-
{actions && (
54-
<div
55-
className="flex items-center shrink-0 py-4 px-2"
56-
onClick={(e) => e.stopPropagation()}
38+
<AccordionPrimitive.Header asChild>
39+
<div className="flex items-center hover:bg-blackAlpha-50 transition-colors w-full min-w-0">
40+
<AccordionPrimitive.Trigger
41+
data-slot="accordion-trigger"
42+
className={cn(
43+
"focus-visible:border-ring focus-visible:ring-ring/50 text-md font-regular flex flex-1 cursor-pointer items-center justify-between gap-4 px-2 py-4 text-left transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180 min-w-0",
44+
className,
45+
)}
46+
{...props}
5747
>
58-
{actions}
59-
</div>
60-
)}
48+
{children}
49+
<Icon
50+
path={mdiChevronDown}
51+
className="transition-transform duration-200 size-6 shrink-0"
52+
/>
53+
</AccordionPrimitive.Trigger>
54+
{actions && (
55+
<div
56+
className="flex items-center shrink-0 py-4 px-2"
57+
onClick={(e) => e.stopPropagation()}
58+
>
59+
{actions}
60+
</div>
61+
)}
62+
</div>
6163
</AccordionPrimitive.Header>
6264
);
6365
}

src/components/ui/calendar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function Calendar({
9292
className={cn("p-3", className)}
9393
captionLayout={captionLayout}
9494
labels={{
95+
labelNav: () => "Month navigation",
9596
...labels,
9697
...(monthDropdownAriaLabel != null && !labels?.labelMonthDropdown
9798
? { labelMonthDropdown: () => monthDropdownAriaLabel }

0 commit comments

Comments
 (0)