Skip to content

Commit 84647d8

Browse files
ENGCOM-6285: The image details are not hidden when click on same image #25566
2 parents 72da0b2 + 63fea91 commit 84647d8

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ define([
107107
show: function (record) {
108108
var img;
109109

110+
if (record._rowIndex === this.visibleRecord()) {
111+
this.hide();
112+
113+
return;
114+
}
115+
110116
this.hide();
111117
this.displayedRecord(record);
112118
this._selectRow(record.rowNumber || null);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
/* eslint-disable max-nested-callbacks, no-undef */
6+
7+
define([
8+
'Magento_Ui/js/grid/columns/image-preview',
9+
'ko',
10+
'jquery'
11+
], function (Preview, ko, $) {
12+
'use strict';
13+
14+
describe('Ui/js/grid/columns/image-preview', function () {
15+
var record = {
16+
_rowIndex: 1,
17+
rowNumber: 1
18+
},
19+
imagePreview;
20+
21+
beforeEach(function () {
22+
imagePreview = new Preview();
23+
24+
/**
25+
* @return {Object}
26+
*/
27+
function getThumbnail() {
28+
return {
29+
previewRowId: ko.observable()
30+
};
31+
}
32+
33+
imagePreview.thumbnailComponent = getThumbnail;
34+
35+
imagePreview.visibleRecord = ko.observable(1);
36+
});
37+
38+
describe('show method', function () {
39+
it('show image', function () {
40+
var mockImg = document.createElement('img'),
41+
hide = spyOn(imagePreview, 'hide');
42+
43+
spyOn($.fn, 'get').and.returnValue(mockImg);
44+
imagePreview.show(record);
45+
expect(hide).toHaveBeenCalledTimes(1);
46+
});
47+
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)