Skip to content

Commit

Permalink
Fixed modals sticking around for Featured Product whens section is re…
Browse files Browse the repository at this point in the history
…moved in the editor (Shopify#3609)
  • Loading branch information
tyleralsbury authored Sep 12, 2024
1 parent 177a0cc commit 259252b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ class ModalDialog extends HTMLElement {
connectedCallback() {
if (this.moved) return;
this.moved = true;
this.dataset.section = this.closest('.shopify-section').id.replace('shopify-section-', '');
document.body.appendChild(this);
}

Expand Down
6 changes: 6 additions & 0 deletions assets/theme-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ document.addEventListener('shopify:section:load', () => {
}
});

document.addEventListener('shopify:section:unload', (event) => {
document.querySelectorAll(`[data-section="${event.detail.sectionId}"]`).forEach((element) => {
element.remove();
});
});

document.addEventListener('shopify:section:reorder', () => hideProductModal());

document.addEventListener('shopify:section:select', () => hideProductModal());
Expand Down

0 comments on commit 259252b

Please sign in to comment.