Skip to content

Commit 959de6c

Browse files
authored
fix: aria-description in SidePanel
1 parent 948c5a9 commit 959de6c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

components/SidePanel/SidePanel.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ export const Basic: StoryFn<typeof SidePanel> = (args) => {
6767
</Box>
6868
</Box>
6969

70-
<SidePanel {...args} open={open} onOpenChange={(isOpen) => setOpen(isOpen)}>
70+
<SidePanel
71+
{...args}
72+
description="Lorem ipsum dolor sit amet"
73+
open={open}
74+
onOpenChange={(isOpen) => setOpen(isOpen)}
75+
>
7176
<Content />
7277
</SidePanel>
7378
</>

components/SidePanel/SidePanel.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as DialogPrimitive from '@radix-ui/react-dialog';
22
import { Cross1Icon } from '@radix-ui/react-icons';
3+
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
34
import React, { ComponentProps } from 'react';
45

56
import { CSS, keyframes, styled, VariantProps } from '../../stitches.config';
@@ -119,6 +120,7 @@ type SidePanelContentPrimitiveProps = React.ComponentProps<typeof DialogPrimitiv
119120
type SidePanelProps = SidePanelContentPrimitiveProps &
120121
SidePanelContentVariants & {
121122
css?: CSS;
123+
description?: string;
122124
noOverlay?: boolean;
123125
noCloseIcon?: boolean;
124126
open?: boolean;
@@ -129,6 +131,7 @@ type SidePanelProps = SidePanelContentPrimitiveProps &
129131
export const SidePanel = React.forwardRef<React.ElementRef<typeof StyledContent>, SidePanelProps>(
130132
(
131133
{
134+
description,
132135
noOverlay = false,
133136
noCloseIcon = false,
134137
children,
@@ -143,6 +146,11 @@ export const SidePanel = React.forwardRef<React.ElementRef<typeof StyledContent>
143146
<DialogPrimitive.Portal>
144147
{!noOverlay && <SidePanelOverlay />}
145148
<StyledContent {...props} ref={forwardedRef}>
149+
{description ? (
150+
<VisuallyHidden asChild>
151+
<DialogPrimitive.Description>{description}</DialogPrimitive.Description>
152+
</VisuallyHidden>
153+
) : null}
146154
{children}
147155
{!noCloseIcon && <SidePanelCloseIconButton />}
148156
</StyledContent>

0 commit comments

Comments
 (0)