Shopify / dawn

Shopify's first source available reference theme, with Online Store 2.0 features and performance built-in.
Other
2.36k stars 3.13k forks source link

Quick add media isn't update on variant change #3448

Closed ludoboludo closed 3 weeks ago

ludoboludo commented 1 month ago

Describe the current behavior

In the quick add modal, for a product that has different variants and images tied to them, if you change the variant it doesn't update the media it's showing you when it should and used to until the previous version 13.0.1.

Describe the expected behavior

When changing variant, the image shown should be updated as well.

Version information (Dawn, browsers and operating systems)

Possible solution

Some refactor was done around product medias and this use case was missed. In updateMedia(html) {...} we're setting the mediaGalleryDestination based on an ID using this.dataset.section but because we've edited those IDs in preventDuplicatedIDs() an added quickadd- in front of it, it's not finding the media list in the new html we're querying. We would need to potentially update this.dataset.section value and remove the quickadd- or something like that.

const mediaGalleryDestination =
      html.querySelector(`[id^="MediaGallery-${this.dataset.section}"] ul`) ||
      html.querySelector(`[id^="MediaGallery-${this.dataset.section.replace('quickadd-', '')}"] ul`);

Additional context/screenshots

Gif of the issue