diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 1ef2ebf6594fa..cf597f8d3a543 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -101,6 +101,12 @@ define([ show: function (record) { var img; + if (record._rowIndex === this.visibleRecord()) { + this.hide(); + + return; + } + this.hide(); this.displayedRecord(record); this._selectRow(record.rowNumber || null); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js new file mode 100644 index 0000000000000..b5c6e75248bfa --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js @@ -0,0 +1,50 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/* eslint-disable max-nested-callbacks, no-undef */ + +define([ + 'Magento_Ui/js/grid/columns/image-preview', + 'ko', + 'jquery' +], function (Preview, ko, $) { + 'use strict'; + + describe('Ui/js/grid/columns/image-preview', function () { + var record = { + _rowIndex: 1, + rowNumber: 1 + }, + imagePreview; + + beforeEach(function () { + imagePreview = new Preview(); + + /** + * @return {Object} + */ + function getThumbnail() { + return { + previewRowId: ko.observable() + }; + } + + imagePreview.thumbnailComponent = getThumbnail; + + imagePreview.visibleRecord = ko.observable(1); + }); + + describe('show method', function () { + it('show image', function () { + var mockImg = document.createElement('img'), + hide = spyOn(imagePreview, 'hide'); + + spyOn($.fn, 'get').and.returnValue(mockImg); + imagePreview.show(record); + expect(hide).toHaveBeenCalledTimes(1); + }); + + }); + }); +});