Skip to content

Commit 154ebc0

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1387: Uncaught TypeError: Cannot read property 'complete' of undefined appears in dev console if save Previewed image as a new View and open this View on another page - created separate function for loading of image data in preview
1 parent 7198c76 commit 154ebc0

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ define([
128128
* @param {Object} record
129129
*/
130130
show: function (record) {
131-
var img;
132-
133131
if (record._rowIndex === this.visibleRecord()) {
134132
this.hide();
135133

@@ -141,19 +139,31 @@ define([
141139
this._selectRow(record.rowNumber || null);
142140
this.visibleRecord(record._rowIndex);
143141

144-
img = $(this.previewImageSelector + ' img');
142+
this.lastOpenedImage(record._rowIndex);
143+
this.updateImageData();
144+
},
145145

146-
if (img.get(0).complete) {
147-
this.updateHeight();
148-
this.scrollToPreview();
146+
/**
147+
* Update image data
148+
*/
149+
updateImageData: function () {
150+
var img = $(this.previewImageSelector + ' img');
151+
152+
if (!img.get(0)) {
153+
setTimeout(function () {
154+
this.updateImageData();
155+
}.bind(this), 100);
149156
} else {
150-
img.load(function () {
157+
if (img.get(0).complete) {
151158
this.updateHeight();
152159
this.scrollToPreview();
153-
}.bind(this));
160+
} else {
161+
img.load(function () {
162+
this.updateHeight();
163+
this.scrollToPreview();
164+
}.bind(this));
165+
}
154166
}
155-
156-
this.lastOpenedImage(record._rowIndex);
157167
},
158168

159169
/**

0 commit comments

Comments
 (0)