Skip to content
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

Merged
merged 3 commits into from
Nov 27, 2019

Conversation

drpayyne
Copy link
Contributor

Description

  • Added left//right arrow navigation for image preview in grid
  • Various checks involved to prevent JS errors
    • Check if image preview is opened
    • Check if Adobe Stock panel is opened
    • Prevent left navigation for first image
    • Prevent right navigation for last image

Fixed Issues

Manual testing scenarios

  1. Open Adobe Stock panel
  2. Open any image preview
  3. Navigate left and right with keyboard arrow keys

@drpayyne drpayyne requested a review from sivaschenko November 14, 2019 19:12
@drpayyne drpayyne requested a review from DrewML as a code owner November 14, 2019 19:12
@m2-assistant
Copy link

m2-assistant bot commented Nov 14, 2019

Hi @drpayyne. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Member

@sivaschenko sivaschenko left a 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,
Copy link
Member

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)

Copy link
Contributor Author

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();
Copy link
Member

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?

Copy link
Contributor Author

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!

$(document).on('keydown', function (e) {
key = keyCodes[e.keyCode];

if ($(adobeModalSelector).hasClass('_show') && $(self.previewImageSelector).length > 0) {
Copy link
Member

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

Suggested change
if ($(adobeModalSelector).hasClass('_show') && $(self.previewImageSelector).length > 0) {
if (this.visibleRecord() !== null) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this, thanks!

*/
setNavigationListener: function () {
var key,
self = this,
Copy link
Member

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';
Copy link
Member

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

@drpayyne
Copy link
Contributor Author

Hi @sivaschenko, I've done your suggested changes, refactored the code to optimize it a bit, and tested too. Thanks!

@drpayyne drpayyne requested a review from sivaschenko November 20, 2019 15:47
Copy link
Member

@sivaschenko sivaschenko left a 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) {
Copy link
Member

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

Suggested change
setNavigationListener: function (e) {
handleKeydown: function (event) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it, thanks!

@drpayyne drpayyne force-pushed the adobe-issue-691 branch 2 times, most recently from f173c8d to d6d4cc6 Compare November 20, 2019 16:08
@drpayyne drpayyne requested a review from sivaschenko November 20, 2019 16:09
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-6331 has been created to process this Pull Request
✳️ @sivaschenko, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Delta
Copy link
Contributor

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Delta, here is your new Magento instance.
Admin access: https://pr-25611.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@engcom-Delta
Copy link
Contributor

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Delta. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-Delta, here is your Magento instance.
Admin access: https://i-25611-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-6331 has been created to process this Pull Request
✳️ @sivaschenko, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@sivaschenko sivaschenko added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Nov 26, 2019
@sivaschenko
Copy link
Member

Covered by functional tests in Adobe Stock Integration

@m2-assistant
Copy link

m2-assistant bot commented Nov 27, 2019

Hi @drpayyne, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants