Skip to content

Fixed issue when the preview images navigation is triggered by moving the input filed cursor using arrow keys #25991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ define([
handleKeyDown: function (e) {
var key = keyCodes[e.keyCode];

if (this.visibleRecord() !== null) {
if (this.visibleRecord() !== null && document.activeElement.tagName !== 'INPUT') {
if (key === 'pageLeftKey') {
this.prev(this.displayedRecord());
} else if (key === 'pageRightKey') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-->
<div data-role="grid-wrapper" class="masonry-image-grid" attr="'data-id': containerId">
<div data-role="grid-wrapper" class="masonry-image-grid" attr="'data-id': containerId" tabindex="0">
<div class="masonry-image-column" repeat="foreach: rows, item: '$row'">
<div outerfasteach="data: getVisible(), as: '$col'" template="getBody()"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,39 @@ define([
});

});

describe('handleKeyDown method', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good also to test the case when the active element is input

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

it('veify record changed on key down', function () {
var recordMock = {
_rowIndex: 2
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nazar65 @engcom-Golf the formatting is not consistent, lines 53-54 require additional indentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

secondRecordMock = {
_rowIndex: 1,
rowNumber: 1
},
elementMock = {
keyCode: 37
},
masonryMock = {
shows: jasmine.createSpy().and.returnValue([]),
rows: jasmine.createSpy().and.returnValue({
1: secondRecordMock
})

},
imageMock = document.createElement('img'),
originMock = $.fn.get;

spyOn($.fn, 'get').and.returnValue(imageMock);
imagePreview.visibleRecord = jasmine.createSpy().and.returnValue(2);
imagePreview.displayedRecord = ko.observable();
imagePreview.displayedRecord(recordMock);
imagePreview.masonry = jasmine.createSpy().and.returnValue(masonryMock);
imagePreview.handleKeyDown(elementMock);
expect(imagePreview.displayedRecord()._rowIndex).toBe(secondRecordMock._rowIndex);
$.fn.get = originMock;
});

});
});
});