diff --git a/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx b/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx index a4a06bf92..ac10ed138 100644 --- a/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx +++ b/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx @@ -7,10 +7,11 @@ import { ToastPosition, useToastsConfiguration, useToasts } from './use-toasts'; import { useCallback } from 'react'; import { Intent } from '../../utils/intent'; -const testToast = { +const TEST_TOAST = { id: 'test-toast', intent: Intent.Primary, content: <>{t('This is an example of a toast notification')}, + onClose: () => useToasts.getState().remove('test-toast'), }; export const ToastPositionSetter = () => { @@ -20,7 +21,7 @@ export const ToastPositionSetter = () => { const handleChange = useCallback( (position: ToastPosition) => { setPostion(position); - setToast(testToast); + setToast(TEST_TOAST); }, [setToast, setPostion] ); diff --git a/libs/ui-toolkit/src/components/toast/use-toasts.ts b/libs/ui-toolkit/src/components/toast/use-toasts.ts index 1f0652ac3..8aff3306c 100644 --- a/libs/ui-toolkit/src/components/toast/use-toasts.ts +++ b/libs/ui-toolkit/src/components/toast/use-toasts.ts @@ -109,12 +109,12 @@ export enum ToastPosition { BottomCenter, } -type ToastConfiguration = { +type ToastsConfiguration = { position: ToastPosition; setPosition: (position: ToastPosition) => void; }; -export const useToastsConfiguration = create()( +export const useToastsConfiguration = create()( persist( immer((set) => ({ position: ToastPosition.BottomRight,