Fix AlertDialog ARIA
This commit is contained in:
parent
3388dbd371
commit
576001f89f
@ -43,8 +43,8 @@ export function AlertDialogContent(props: AlertDialogContentProps): JSX.Element
|
|||||||
id={ctx.contentId()}
|
id={ctx.contentId()}
|
||||||
role="alertdialog"
|
role="alertdialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-labelledby={ctx.titleId() ?? undefined}
|
aria-labelledby={ctx.titleId() || undefined}
|
||||||
aria-describedby={ctx.descriptionId() ?? undefined}
|
aria-describedby={ctx.descriptionId() || undefined}
|
||||||
data-state={ctx.isOpen() ? "open" : "closed"}
|
data-state={ctx.isOpen() ? "open" : "closed"}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -13,8 +13,11 @@ import {
|
|||||||
|
|
||||||
/** Props for the AlertDialog root. */
|
/** Props for the AlertDialog root. */
|
||||||
export interface AlertDialogRootProps {
|
export interface AlertDialogRootProps {
|
||||||
|
/** Controls open state externally. */
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
|
/** Initial open state when uncontrolled. */
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
|
/** Called when open state changes. */
|
||||||
onOpenChange?: (open: boolean) => void;
|
onOpenChange?: (open: boolean) => void;
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,14 @@ export function AlertDialogTrigger(props: AlertDialogTriggerProps): JSX.Element
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button type="button" aria-haspopup="dialog" onClick={handleClick} {...rest}>
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-controls={ctx.contentId()}
|
||||||
|
aria-expanded={ctx.isOpen() ? "true" : "false"}
|
||||||
|
onClick={handleClick}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
{local.children}
|
{local.children}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user