Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { registry } from "@web/core/registry";
import { NoBackdropPopup } from "./no_backdrop_popup";

export const NoBackdropPopupEdit = (I) => class extends I {
setup() {
super.setup();
if (this.el.classList.contains("show")) {
// Use case: When the "Backdrop" option is disabled in edit mode.
// The page scrollbar must be adjusted and events must be added.
this.addModalNoBackdropEvents();
}
}
};

registry
.category("website.editable_active_elements_builders")
.add("website.no_backdrop_popup", {
Interaction: NoBackdropPopup,
mixin: NoBackdropPopupEdit
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Interaction } from "@website/core/interaction";

export class NoBackdropPopup extends Interaction {
static selector = ".s_popup_no_backdrop";
// TODO: handle edit mode
// disabledInEditableMode = false;
dynamicContent = {
"_root": {
"t-on-shown.bs.modal": this.addModalNoBackdropEvents,
Expand All @@ -17,12 +15,6 @@ export class NoBackdropPopup extends Interaction {
this.throttledUpdateScrollbar = this.throttledForAnimation(this.updateScrollbar);
this.removeResizeListener = null;
this.resizeObserver = null;
// TODO: handle edit mode
// if (this.editableMode && this.el.classList.contains("show")) {
// // Use case: When the "Backdrop" option is disabled in edit mode.
// // The page scrollbar must be adjusted and events must be added.
// this.addModalNoBackdropEvents();
// }
}

destroy() {
Expand Down
12 changes: 3 additions & 9 deletions addons/website/static/src/interactions/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export class Popup extends Interaction {
this.modalEl = this.el.querySelector(".modal");
/** @type {import("bootstrap").Modal} */
this.bsModal = window.Modal.getOrCreateInstance(this.modalEl);
this.registerCleanup(() => {
this.bsModal.dispose();
});

this.modalShownOnClickEl = this.el.querySelector(".modal[data-display='onClick']");
if (this.modalShownOnClickEl) {
Expand Down Expand Up @@ -60,15 +63,6 @@ export class Popup extends Interaction {
}
}

destroy() {
// You cannot hide after dispose, so we do both here to make sure they
// trigger in order. The cleanup is not registered in setup so that the
// hide.bs.modal event isn't triggered (it is cleaned before destroy),
// and no cookie is set.
this.bsModal.hide();
this.bsModal.dispose();
}

bindPopup() {
let display = this.modalEl.dataset.display;
let delay = parseInt(this.modalEl.dataset.showAfter);
Expand Down
20 changes: 7 additions & 13 deletions addons/website/static/src/interactions/popup/shared_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { Interaction } from "@website/core/interaction";

export class SharedPopup extends Interaction {
static selector = ".s_popup";
// TODO: support edit mode
disabledInEditableMode = false;
dynamicContent = {
// A popup element is composed of a `.s_popup` parent containing the
// actual `.modal` BS modal. Our internal logic and events are hiding
Expand All @@ -28,16 +26,6 @@ export class SharedPopup extends Interaction {

setup() {
this.popupShown = false;

// TODO: support edit mode, maybe this can be removed completely.
// Popup are always closed when entering edit mode (see Popup interaction),
// this allows to make sure the class is sync on the .s_popup parent
// after that moment too.
// if (!this.editableMode) {
this.registerCleanup(() => {
this.popupShown = false;
});
// }
}

onModalHidden() {
Expand All @@ -52,4 +40,10 @@ export class SharedPopup extends Interaction {
}
}

registry.category("website.active_elements").add("website.shared_popup", SharedPopup);
registry
.category("website.active_elements")
.add("website.shared_popup", SharedPopup);

registry
.category("website.editable_active_elements_builders")
.add("website.shared_popup", { Interaction: SharedPopup });