Skip to content

Commit

Permalink
magento/adobe-stock-integration#1387: Uncaught TypeError: Cannot read…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
joweecaquicla committed Aug 18, 2020
1 parent 7198c76 commit 154ebc0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ define([
* @param {Object} record
*/
show: function (record) {
var img;

if (record._rowIndex === this.visibleRecord()) {
this.hide();

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

img = $(this.previewImageSelector + ' img');
this.lastOpenedImage(record._rowIndex);
this.updateImageData();
},

if (img.get(0).complete) {
this.updateHeight();
this.scrollToPreview();
/**
* Update image data
*/
updateImageData: function () {
var img = $(this.previewImageSelector + ' img');

if (!img.get(0)) {
setTimeout(function () {
this.updateImageData();
}.bind(this), 100);
} else {
img.load(function () {
if (img.get(0).complete) {
this.updateHeight();
this.scrollToPreview();
}.bind(this));
} else {
img.load(function () {
this.updateHeight();
this.scrollToPreview();
}.bind(this));
}
}

this.lastOpenedImage(record._rowIndex);
},

/**
Expand Down

0 comments on commit 154ebc0

Please sign in to comment.