File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed
samples/react/src/components/toast Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ export class KolToastContainer implements ToasterAPI {
7474 ...this . state ,
7575 _toastStates : this . state . _toastStates . filter ( ( localToastState ) => localToastState . id !== toastState . id ) ,
7676 } ;
77+ toastState . toast . onClose ?.( ) ;
7778 } , TRANSITION_TIMEOUT ) ;
7879 }
7980
@@ -101,6 +102,9 @@ export class KolToastContainer implements ToasterAPI {
101102 ...this . state ,
102103 _toastStates : this . state . _toastStates . filter ( ( toastState ) => toastsToClose . every ( ( toastToClose ) => toastToClose . id !== toastState . id ) ) ,
103104 } ;
105+ toastsToClose . forEach ( ( toastState ) => {
106+ toastState . toast . onClose ?.( ) ;
107+ } ) ;
104108 } , TRANSITION_TIMEOUT ) ;
105109 }
106110 }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export type Toast = {
1414 label : LabelPropType ;
1515 type : AlertType ;
1616 variant ?: AlertVariant ;
17+ onClose ?: ( ) => void ;
1718} ;
1819
1920export type ToastState = {
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ export const ToastBasic: FC = () => {
2020 description : 'Toasty' ,
2121 label : `Initial Toast` ,
2222 type : 'warning' ,
23+ onClose : ( ) => {
24+ console . log ( 'Simple toast has been closed.' ) ;
25+ } ,
2326 } ) ;
2427 } ;
2528
You can’t perform that action at this time.
0 commit comments