Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup fixes #4218

Merged
merged 3 commits into from
Mar 26, 2025
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
Expand Up @@ -6,7 +6,6 @@ export class EditInteractionPlugin extends Plugin {

resources = {
normalize_handlers: this.restartInteractions.bind(this),
option_visibility_updated: this.restartInteractions.bind(this),
content_manually_updated_handlers: this.restartInteractions.bind(this),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,12 @@ class PopupOptionPlugin extends Plugin {
// save (see save plugin) and Bootstrap moves it if it is not within the
// document (see Bootstrap Modal's _showElement).
if (target.matches(".s_popup") && this.editable.contains(target)) {
const modalEl = target.querySelector(".modal");
this.window.Modal.getOrCreateInstance(modalEl).show();
target.classList.remove("d-none");
this.window.Modal.getOrCreateInstance(target.querySelector(".modal")).show();
}
}

onTargetHide(target) {
if (target.matches(".s_popup")) {
target.classList.add("d-none");
this.window.Modal.getOrCreateInstance(target.querySelector(".modal")).hide();
}
}
Expand All @@ -138,6 +135,7 @@ class PopupOptionPlugin extends Plugin {
modalEl.parentElement.dataset.invisible = "1";
// Do not call .hide() directly, because it is queued whereas
// .dispose() is not.
modalEl.classList.remove("show");
this.window.Modal.getOrCreateInstance(modalEl)._hideModal();
this.window.Modal.getInstance(modalEl).dispose();
}
Expand Down
6 changes: 1 addition & 5 deletions addons/web/static/src/public/interaction_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ class InteractionService {
stopInteractions(el = this.el) {
const interactions = [];
for (const interaction of this.interactions.slice().reverse()) {
if (
el === interaction.el ||
el.contains(interaction.el) ||
interaction.el.closest("[data-invisible='1']")
) {
if (el === interaction.el || el.contains(interaction.el)) {
interaction.destroy();
this.activeInteractions.delete(interaction.el, interaction.interaction.constructor);
} else {
Expand Down
6 changes: 0 additions & 6 deletions addons/website/static/src/core/website_edit_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ PublicRoot.include({
// Patch Colibri.

patch(Colibri.prototype, {
async start() {
if (this.el.closest("[data-invisible='1']")) {
return;
}
return super.start();
},
protectSyncAfterAsync(interaction, name, fn) {
fn = super.protectSyncAfterAsync(interaction, name, fn);
const fullName = `${interaction.constructor.name}/${name}`;
Expand Down
1 change: 1 addition & 0 deletions addons/website/static/src/interactions/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class Popup extends Interaction {
// animations here, bypass the issue with ._hideModal().
// Additionally, .hide() triggers `hide.bs.modal`, which triggers
// onHideModal() and sets a cookie: we don't want that on destroy.
this.modalEl.classList.remove("show");
this.bsModal._hideModal();
});
}
Expand Down
12 changes: 8 additions & 4 deletions addons/website/static/src/interactions/popup/shared_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ export class SharedPopup extends Interaction {
// ugly white bar.
// tl;dr: this is keeping those 2 elements visibility synchronized.
_root: {
"t-on-show.bs.modal": () => this.popupShown = true,
"t-on-show.bs.modal.noUpdate": () => {
this.popupShown = true;
// Combining noUpdate and `this.updateContent()` forces a
// repaint immediately to remove `.d-none` before the transition
// happens. Otherwise, the transition isn't visible.
this.updateContent();
},
"t-on-shown.bs.modal": () => this.popupShown = true,
"t-on-hidden.bs.modal": this.onModalHidden,
"t-att-class": () => ({
"d-none": !this.popupShown,
}),
"t-att-class": () => ({ "d-none": !this.popupShown }),
},
};

Expand Down