@@ -93,6 +93,11 @@ export namespace INotification {
93
93
export interface IOptions {
94
94
/** List of buttons with callback action to include in a toast */
95
95
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 ;
96
101
}
97
102
98
103
/**
@@ -148,7 +153,7 @@ export namespace INotification {
148
153
{
149
154
type : "error" ,
150
155
className : "jp-toast-error" ,
151
- autoClose : false
156
+ autoClose : ( options && options . autoClose ) || false
152
157
}
153
158
) ;
154
159
@@ -169,7 +174,7 @@ export namespace INotification {
169
174
{
170
175
type : "warning" ,
171
176
className : "jp-toast-warning" ,
172
- autoClose : false
177
+ autoClose : ( options && options . autoClose ) || false
173
178
}
174
179
) ;
175
180
@@ -184,7 +189,10 @@ export namespace INotification {
184
189
message : React . ReactNode ,
185
190
options ?: IOptions
186
191
) : 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 ;
188
196
return toast (
189
197
( { closeToast } : { closeToast : ( ) => void } ) =>
190
198
createToast ( message , closeToast , options ) ,
@@ -207,7 +215,10 @@ export namespace INotification {
207
215
message : React . ReactNode ,
208
216
options ?: IOptions
209
217
) : 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 ;
211
222
return toast (
212
223
( { closeToast } : { closeToast : ( ) => void } ) =>
213
224
createToast ( message , closeToast , options ) ,
@@ -236,7 +247,7 @@ export namespace INotification {
236
247
{
237
248
type : "default" ,
238
249
className : "jp-toast-inprogress" ,
239
- autoClose : false
250
+ autoClose : ( options && options . autoClose ) || false
240
251
}
241
252
) ;
242
253
@@ -286,12 +297,12 @@ export namespace INotification {
286
297
// Needs to recreate a closed toast
287
298
options . toastId = args . toastId ;
288
299
if ( ! options . type ) {
289
- // If not type specifed , assumes it is `in progress`
300
+ // If not type specified , assumes it is `in progress`
290
301
options = {
291
302
...options ,
292
303
type : "default" ,
293
304
className : "jp-toast-inprogress" ,
294
- autoClose : false
305
+ autoClose : options . autoClose || false
295
306
} ;
296
307
}
297
308
toast ( options . render , options ) ;
0 commit comments