-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Added keyboard navigation for Adobe Stock image previews #25611
Added keyboard navigation for Adobe Stock image previews #25611
Conversation
Hi @drpayyne. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @drpayyne thank you for the pull request, please check my review comments
* Set image preview keyboard navigation listener | ||
*/ | ||
setNavigationListener: function () { | ||
var imageIndex, endIndex, key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think start and endIndex should be handled here. They should be handled in next and prev methods (if it is currently possible to trigger them for first/last image)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this too, thank you for your guidance!
if(key === 'pageLeftKey' && imageIndex !== startIndex) { | ||
$(this.previewImageSelector + ' .action-previous').click(); | ||
} else if (key === 'pageRightKey' && imageIndex !== endIndex) { | ||
$(this.previewImageSelector + ' .action-next').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't next/prev methods of this component be called directly instead of triggering a click?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realize displayedRecord
property can be used for that purpose. Fixed it now, thank you!
9e04804
to
05285c2
Compare
$(document).on('keydown', function (e) { | ||
key = keyCodes[e.keyCode]; | ||
|
||
if ($(adobeModalSelector).hasClass('_show') && $(self.previewImageSelector).length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to unbind this check from visual representation as well
if ($(adobeModalSelector).hasClass('_show') && $(self.previewImageSelector).length > 0) { | |
if (this.visibleRecord() !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this, thanks!
05285c2
to
5e45173
Compare
*/ | ||
setNavigationListener: function () { | ||
var key, | ||
self = this, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bind this to function instead of using self variable
setNavigationListener: function () { | ||
var key, | ||
self = this, | ||
adobeModalSelector = '.adobe-stock-modal'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not used
5e45173
to
0afb5d3
Compare
Hi @sivaschenko, I've done your suggested changes, refactored the code to optimize it a bit, and tested too. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updates! One more issue arose after the reorganization of the code:
/** | ||
* Set image preview keyboard navigation listener | ||
*/ | ||
setNavigationListener: function (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the reorganization, the better name for the function would be 'handleKeydown'. Please add the method params/return to the docblock and update the comment to be up to date with the actual method purpose
setNavigationListener: function (e) { | |
handleKeydown: function (event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it, thanks!
f173c8d
to
d6d4cc6
Compare
Hi @sivaschenko, thank you for the review.
|
d6d4cc6
to
1298766
Compare
@magento give me test instance |
Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you |
Hi @engcom-Delta, here is your new Magento instance. |
@magento give me 2.3-develop instance |
Hi @engcom-Delta. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @engcom-Delta, here is your Magento instance. |
✔️ QA passed |
Hi @sivaschenko, thank you for the review.
|
Covered by functional tests in Adobe Stock Integration |
Hi @drpayyne, thank you for your contribution! |
Description
Fixed Issues
Manual testing scenarios