Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dialog add attributes #2885

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-moose-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ultraviolet/ui': patch
---

feat: add more accessibility to our modal
3 changes: 0 additions & 3 deletions packages/ui/src/components/ActionBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type ActionBarProps = {
*/
rank?: number
role?: string
'aria-modal'?: 'true' | 'false'
className?: string
'data-testid'?: string
}
Expand All @@ -35,15 +34,13 @@ export const ActionBar = ({
children,
role = 'dialog',
rank = 0,
'aria-modal': ariaModal = 'true',
className,
'data-testid': dataTestId,
}: ActionBarProps) =>
createPortal(
<StyledDiv
rank={rank}
role={role}
aria-modal={ariaModal}
className={className}
data-testid={dataTestId}
>
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/Modal/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const Dialog = ({
data-size={size}
open={open}
onClick={stopClick}
aria-modal
>
{open ? children : null}
</StyledDialog>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/Modal/Disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const Disclosure = ({
return cloneElement(disclosure, {
...disclosure.props,
ref: disclosureRef,
'aria-controls': id,
'aria-haspopup': 'dialog',
} as unknown as PropsWithRef<typeof disclosure>)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ exports[`Modal renders opened custom size 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="medium"
Expand Down Expand Up @@ -391,6 +392,7 @@ exports[`Modal renders opened custom size and width (size take predecence) 1`] =
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="medium"
Expand Down Expand Up @@ -603,6 +605,7 @@ exports[`Modal renders opened custom width 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="medium"
Expand Down Expand Up @@ -815,6 +818,7 @@ exports[`Modal renders with custom classNames 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="1vjuh1t-customDialogStyles cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down Expand Up @@ -1029,6 +1033,7 @@ exports[`Modal renders with customStyle 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-550m4a-StyledDialog-customDialogStyles e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down Expand Up @@ -1065,6 +1070,8 @@ exports[`Modal renders with customStyle 1`] = `
exports[`Modal renders with default Props 1`] = `
<DocumentFragment>
<button
aria-controls=":r0:"
aria-haspopup="dialog"
type="button"
>
Test
Expand Down Expand Up @@ -1253,6 +1260,7 @@ exports[`Modal renders with default Props and function children opened 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down Expand Up @@ -1289,6 +1297,8 @@ exports[`Modal renders with default Props and function children opened 1`] = `
exports[`Modal renders with disclosure 1`] = `
<DocumentFragment>
<button
aria-controls="modal-test"
aria-haspopup="dialog"
type="button"
>
Test
Expand Down Expand Up @@ -1491,6 +1501,7 @@ exports[`Modal renders with disclosure and onClose 1`] = `
>
<dialog
aria-label="modal-test"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down Expand Up @@ -1705,6 +1716,7 @@ exports[`Modal renders with opened={true} 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down Expand Up @@ -1854,6 +1866,7 @@ exports[`Modal renders with opened={true} and no close icon 1`] = `
>
<dialog
aria-label="modal"
aria-modal="true"
class="cache-ycaaob-StyledDialog e1cqen9h0"
data-placement="center"
data-size="small"
Expand Down
Loading