diff --git a/src/core/containerObserver.ts b/src/core/containerObserver.ts index efa68925..b4551ea0 100644 --- a/src/core/containerObserver.ts +++ b/src/core/containerObserver.ts @@ -151,9 +151,12 @@ export function createContainerObserver( const { onClose, children } = toastToRemove.props; if (isFn(onClose)) onClose(isValidElement(children) && children.props); - !closedByButton - ? dispatchChanges(toToastItem(toastToRemove, 'removed')) - : dispatchChanges(toToastItem(toastToRemove, 'removed by button')); + dispatchChanges( + toToastItem( + toastToRemove, + !closedByButton ? 'removed' : 'removed by button' + ) + ); toasts.delete(toastId); closedByButton = false; diff --git a/src/core/toast.cy.tsx b/src/core/toast.cy.tsx index 7ccde44c..e20b3db2 100644 --- a/src/core/toast.cy.tsx +++ b/src/core/toast.cy.tsx @@ -87,7 +87,7 @@ describe('with container', () => { it('remove toast by button', () => { toast.onChange(cy.stub().as('onChange')); - + toast('msg', { data: 'xxxx' }); cy.resolveEntranceAnimation();