discourse/app/assets/javascripts/float-kit/addon/lib/d-toast-instance.js
Joffrey JAFFEUX bd7823cc70
FIX: prevents mobile DMenu modal to lock scroll (#26550)
The bug was due to the fact that the `<DModal />` is displayed inside a if block, when the condition was false to close the menu, the modal was just hidden without calling callbacks. The fix ensures we are correctly calling `modal.close()` before in this case.
2024-04-08 09:47:50 +02:00

30 lines
651 B
JavaScript

import { setOwner } from "@ember/application";
import { action } from "@ember/object";
import { service } from "@ember/service";
import uniqueId from "discourse/helpers/unique-id";
import { TOAST } from "float-kit/lib/constants";
export default class DToastInstance {
@service site;
@service toasts;
options = null;
id = uniqueId();
constructor(owner, options = {}) {
setOwner(this, owner);
this.options = { ...TOAST.options, ...options };
}
@action
close() {
this.toasts.close(this);
}
get isValidForView() {
return this.options.views.includes(
this.site.desktopView ? "desktop" : "mobile"
);
}
}