Skip to content
Merged
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions src/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ export const Alert = memo(
closable: isClosableByUser = false,
isClosed: props_isClosed,
onClose,
role = "alert",
role: roleFromProps,
...rest
} = props;

// Honour explicit `role={undefined}` to opt out of the role attribute (RGAA 8.7).
// When role is omitted entirely, default to "alert" for screen reader announcements.
const role = "role" in props ? roleFromProps : ("alert" as const);

assert<Equals<keyof typeof rest, never>>();

const id = useAnalyticsId({
Expand Down Expand Up @@ -147,8 +151,8 @@ export const Alert = memo(
className
)}
style={style}
{...(refShouldSetRole.current && { "role": role })}
{...(role ? { "role": role } : {})}
{...(refShouldSetRole.current && role !== undefined && { "role": role })}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

à quoi sert cette ligne, c'est toujours écrasé en-dessous, non ?

{...(role !== undefined ? { "role": role } : {})}
ref={ref}
{...rest}
>
Expand Down