Closed ludoboludo closed 3 weeks ago
Could we perhaps use this functionality instead? It would follow similar logic used elsewhere in global.js. The problem seems to originate with how Section Rendering API now works.
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-${sectionId}"] ul`);
PR Summary:
In the quick add modal, on version 14, when you change variant it doesn't update media shown when it used to.
Why are these changes introduced?
Fixes https://github.com/Shopify/dawn/issues/3448
What approach did you take?
From what I see it's looking a
mediaGalleyDestination
but it can't grab any causethis.dataset.section
can't be found in the newhtml
. (recording)With this new approach, it seems like the issue comes from the fact that we have
preventDuplicatedIDs()
to prevent duplicate IDs in the quick add modal by addingquickadd-
. So when we doIt's not finding that destination as it doesn't have a similar
ID
. ~We could tweak thatdata-section
and remove thequickadd-
withinupdateMedia(html){...}
🤷~In the function that prevents the duplicate IDs we're setting a data attribute that keeps the original section ID. So we're using this in priority if it's present and we don't need to do the string manipulation 👍
If I do this instead it seem to fix the issue:
Visual impact on existing themes
It now works when changing variant that has a feat. image
Testing steps/scenarios
Demo links
Checklist