Skip to content

An opinionated toast component for React.

fix: turn section into live region #306 (#436)

Bogdan Lazar971bfe1d77ed
diff --git a/src/index.tsx b/src/index.tsx
index a3b807d..74cc2e9 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -243,9 +243,6 @@ const Toast = (props: ToastProps) => {
return (
<li
- aria-live={toast.important ? 'assertive' : 'polite'}
- aria-atomic="true"
- role="status"
tabIndex={0}
ref={toastRef}
className={cn(
@@ -644,13 +641,14 @@ const Toaster = forwardRef<HTMLElement, ToasterProps>(function Toaster(props, re
}
}, [listRef.current]);
- if (!toasts.length) return null;
-
return (
// Remove item from normal navigation flow, only available via hotkey
- <section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1} ref={ref}>
+ <section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1} aria-live="polite" aria-relevant="additions text" aria-atomic="false">
{possiblePositions.map((position, index) => {
const [y, x] = position.split('-');
+
+ if (!toasts.length) return null;
+
return (
<ol
key={position}
diff --git a/src/types.ts b/src/types.ts
index 1011574..5e03a89 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -65,7 +65,6 @@ export interface ToastT {
description?: (() => React.ReactNode) | React.ReactNode;
duration?: number;
delete?: boolean;
- important?: boolean;
action?: Action | React.ReactNode;
cancel?: Action | React.ReactNode;
onDismiss?: (toast: ToastT) => void;