From 1d98d3c68eac9beacf194704966e4a1f1068ba33 Mon Sep 17 00:00:00 2001 From: Ludo Date: Fri, 3 May 2024 10:52:26 +0200 Subject: [PATCH 1/2] Fix variant media not changing in the quick add modal --- assets/global.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/global.js b/assets/global.js index e4324460f8c..b25786c719b 100644 --- a/assets/global.js +++ b/assets/global.js @@ -1104,7 +1104,9 @@ class VariantSelects extends HTMLElement { updateMedia(html) { const mediaGallerySource = document.querySelector(`[id^="MediaGallery-${this.dataset.section}"] ul`); - const mediaGalleryDestination = html.querySelector(`[id^="MediaGallery-${this.dataset.section}"] ul`); + const mediaGalleryDestination = html.querySelector( + `[id^="MediaGallery-${this.dataset.section.replace('quickadd-', '')}"] ul` + ); const refreshSourceData = () => { const mediaGallerySourceItems = Array.from(mediaGallerySource.querySelectorAll('li[data-media-id]')); From ef0cf34c8ee47a8e9d2983b986e7889b19a0fa8b Mon Sep 17 00:00:00 2001 From: Ludo Date: Mon, 6 May 2024 11:56:20 +0200 Subject: [PATCH 2/2] update approach based on review's feedback --- assets/global.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/global.js b/assets/global.js index b25786c719b..3ccdd967de9 100644 --- a/assets/global.js +++ b/assets/global.js @@ -1103,10 +1103,9 @@ class VariantSelects extends HTMLElement { } updateMedia(html) { + const sectionId = this.dataset.originalSection ? this.dataset.originalSection : this.dataset.section; const mediaGallerySource = document.querySelector(`[id^="MediaGallery-${this.dataset.section}"] ul`); - const mediaGalleryDestination = html.querySelector( - `[id^="MediaGallery-${this.dataset.section.replace('quickadd-', '')}"] ul` - ); + const mediaGalleryDestination = html.querySelector(`[id^="MediaGallery-${sectionId}"] ul`); const refreshSourceData = () => { const mediaGallerySourceItems = Array.from(mediaGallerySource.querySelectorAll('li[data-media-id]'));