Skip to content

Commit

Permalink
a11y(Alert): give Alert alertdialog role (#6846)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvandercar-vt authored Jun 26, 2024
1 parent 605d318 commit f9a1b48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export class Alert extends AbstractPureComponent<AlertProps> {
return (
<Dialog
{...overlayProps}
role="alertdialog"
className={classNames(Classes.ALERT, className)}
canEscapeKeyClose={canEscapeKeyCancel}
canOutsideClickClose={canOutsideClickCancel}
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export interface DialogProps extends OverlayableProps, BackdropProps, Props {
*/
isCloseButtonShown?: boolean;

/**
* @default "dialog"
*/
role?: Extract<React.AriaRole, "dialog" | "alertdialog">;

/**
* CSS styles to apply to the dialog.
*
Expand Down Expand Up @@ -128,7 +133,7 @@ export class Dialog extends AbstractPureComponent<DialogProps> {
}

public render() {
const { className, children, containerRef, style, title, ...overlayProps } = this.props;
const { className, children, containerRef, style, title, role = "dialog", ...overlayProps } = this.props;

return (
<Overlay2
Expand All @@ -143,7 +148,8 @@ export class Dialog extends AbstractPureComponent<DialogProps> {
>
<div
className={classNames(Classes.DIALOG, className)}
role="dialog"
role={role}
aria-modal={overlayProps.enforceFocus ?? Overlay2.defaultProps?.enforceFocus}
aria-labelledby={this.props["aria-labelledby"] || (title ? this.titleId : undefined)}
aria-describedby={this.props["aria-describedby"]}
style={style}
Expand Down

1 comment on commit f9a1b48

@svc-palantir-github
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a11y(Alert): give Alert alertdialog role (#6846)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.