mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add option to float-kit toast to force auto-close (#24022)
This commit is contained in:
committed by
GitHub
parent
00aa81a271
commit
cfbe16f9cc
@@ -70,6 +70,7 @@ import DDefaultToast from "float-kit/components/d-default-toast";
|
||||
export const TOAST = {
|
||||
options: {
|
||||
autoClose: true,
|
||||
forceAutoClose: false,
|
||||
duration: 3000,
|
||||
component: DDefaultToast,
|
||||
},
|
||||
|
||||
@@ -46,6 +46,11 @@ export default class DToastInstance {
|
||||
|
||||
@action
|
||||
cancelAutoClose() {
|
||||
if (this.options.forceAutoClose) {
|
||||
// Return early so that we do not cancel the autoClose timer.
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(this.autoCloseHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ export default class Toasts extends Service {
|
||||
*
|
||||
* @param {Object} [options] - options passed to the toast component as `@toast` argument
|
||||
* @param {String} [options.duration] - The duration (ms) of the toast, will be closed after this time
|
||||
* @param {Boolean} [options.autoClose=true] - When true, the toast will autoClose after the duration
|
||||
* @param {Boolean} [options.forceAutoClose=false] - When true, toast will still autoClose following mouseover event
|
||||
* @param {ComponentClass} [options.component] - A component to render, will use `DDefaultToast` if not provided
|
||||
* @param {String} [options.class] - A class added to the d-toast element
|
||||
* @param {Object} [options.data] - An object which will be passed as the `@data` argument to the component
|
||||
|
||||
Reference in New Issue
Block a user