@@ -93,6 +93,11 @@ export namespace INotification {
9393 export interface IOptions {
9494 /** List of buttons with callback action to include in a toast */
9595 buttons ?: Array < IButton > ;
96+ /**
97+ * Autoclosing behavior - undefined (not closing automatically)
98+ * or number (time in milliseconds before closing a toast)
99+ */
100+ autoClose ?: number ;
96101 }
97102
98103 /**
@@ -148,7 +153,7 @@ export namespace INotification {
148153 {
149154 type : "error" ,
150155 className : "jp-toast-error" ,
151- autoClose : false
156+ autoClose : ( options && options . autoClose ) || false
152157 }
153158 ) ;
154159
@@ -169,7 +174,7 @@ export namespace INotification {
169174 {
170175 type : "warning" ,
171176 className : "jp-toast-warning" ,
172- autoClose : false
177+ autoClose : ( options && options . autoClose ) || false
173178 }
174179 ) ;
175180
@@ -184,7 +189,10 @@ export namespace INotification {
184189 message : React . ReactNode ,
185190 options ?: IOptions
186191 ) : number => {
187- let autoClose = options && options . buttons . length > 0 ? false : undefined ;
192+ let autoClose =
193+ options && options . buttons . length > 0
194+ ? options . autoClose || false
195+ : undefined ;
188196 return toast (
189197 ( { closeToast } : { closeToast : ( ) => void } ) =>
190198 createToast ( message , closeToast , options ) ,
@@ -207,7 +215,10 @@ export namespace INotification {
207215 message : React . ReactNode ,
208216 options ?: IOptions
209217 ) : number => {
210- let autoClose = options && options . buttons . length > 0 ? false : undefined ;
218+ let autoClose =
219+ options && options . buttons . length > 0
220+ ? options . autoClose || false
221+ : undefined ;
211222 return toast (
212223 ( { closeToast } : { closeToast : ( ) => void } ) =>
213224 createToast ( message , closeToast , options ) ,
@@ -236,7 +247,7 @@ export namespace INotification {
236247 {
237248 type : "default" ,
238249 className : "jp-toast-inprogress" ,
239- autoClose : false
250+ autoClose : ( options && options . autoClose ) || false
240251 }
241252 ) ;
242253
@@ -286,12 +297,12 @@ export namespace INotification {
286297 // Needs to recreate a closed toast
287298 options . toastId = args . toastId ;
288299 if ( ! options . type ) {
289- // If not type specifed , assumes it is `in progress`
300+ // If not type specified , assumes it is `in progress`
290301 options = {
291302 ...options ,
292303 type : "default" ,
293304 className : "jp-toast-inprogress" ,
294- autoClose : false
305+ autoClose : options . autoClose || false
295306 } ;
296307 }
297308 toast ( options . render , options ) ;
0 commit comments