Skip to content

Commit 95d5f44

Browse files
author
niravkrish
committed
Fixed Code Improovement
1 parent b92bbc4 commit 95d5f44

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,6 @@ define([
12231223
}
12241224

12251225
imagesToUpdate = this._setImageIndex(imagesToUpdate);
1226-
12271226
if (gallery === undefined) {
12281227
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) {
12291228
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery');
@@ -1242,7 +1241,14 @@ define([
12421241
});
12431242
}
12441243

1245-
gallery.first();
1244+
if (gallery === undefined) {
1245+
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) {
1246+
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery');
1247+
loadedGallery.first();
1248+
}.bind(this));
1249+
} else {
1250+
gallery.first();
1251+
}
12461252

12471253
} else if (justAnImage && justAnImage.img) {
12481254
context.find('.product-image-photo').attr('src', justAnImage.img);

0 commit comments

Comments
 (0)