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.
This commit is contained in:
Joffrey JAFFEUX 2024-04-08 09:47:50 +02:00 committed by GitHub
parent 62788c2af1
commit bd7823cc70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import FloatKitInstance from "float-kit/lib/float-kit-instance";
export default class DMenuInstance extends FloatKitInstance {
@service menu;
@service site;
@service modal;
constructor(owner, trigger, options = {}) {
super(...arguments);
@ -18,6 +20,15 @@ export default class DMenuInstance extends FloatKitInstance {
this.setupListeners();
}
@action
close() {
if (this.site.mobileView && this.options.modalForMobile) {
this.modal.close();
}
super.close(...arguments);
}
@action
onMouseMove(event) {
if (this.trigger.contains(event.target) && this.expanded) {

View File

@ -22,6 +22,8 @@ export default class DToastInstance {
}
get isValidForView() {
return this.options.views.includes(this.site.desktopView ? "desktop" : "mobile");
return this.options.views.includes(
this.site.desktopView ? "desktop" : "mobile"
);
}
}