diff --git a/src/core/store.ts b/src/core/store.ts index 4909dcf..8eedccf 100644 --- a/src/core/store.ts +++ b/src/core/store.ts @@ -141,6 +141,11 @@ export const defaultTimeouts: { custom: 4000, }; +const defaultAriaProps = { + role: 'status', + 'aria-live': 'polite', +} as const; + export const useStore = (toastOptions: DefaultToastOptions = {}): State => { const [state, setState] = useState(memoryState); useEffect(() => { @@ -154,6 +159,7 @@ export const useStore = (toastOptions: DefaultToastOptions = {}): State => { }, [state]); const mergedToasts = state.toasts.map((t) => ({ + ariaProps: defaultAriaProps, ...toastOptions, ...toastOptions[t.type], ...t, diff --git a/src/core/toast.ts b/src/core/toast.ts index 2be7811..5970fa4 100644 --- a/src/core/toast.ts +++ b/src/core/toast.ts @@ -23,10 +23,6 @@ const createToast = ( visible: true, dismissed: false, type, - ariaProps: { - role: 'status', - 'aria-live': 'polite', - }, message, pauseDuration: 0, ...opts, diff --git a/src/core/types.ts b/src/core/types.ts index 1085db6..032cb53 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -41,7 +41,7 @@ export interface Toast { position?: ToastPosition; removeDelay?: number; - ariaProps: { + ariaProps?: { role: 'status' | 'alert'; 'aria-live': 'assertive' | 'off' | 'polite'; };