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

Keyboard navigation for media editor #2108

Merged
merged 11 commits into from Aug 31, 2020
Merged

Keyboard navigation for media editor #2108

merged 11 commits into from Aug 31, 2020

Conversation

wassgha
Copy link
Contributor

@wassgha wassgha commented May 29, 2020

Summary

Adds ability to move the cropped image/video using keyboard arrows.

To-do

  • Fix warning while setting framesLayer ref
  • Restore keyboard events for dragging after finishing (otherwise dragging by keyboard will be disabled)
  • Refactor code to prevent duplication between drag callbacks and keyboard callbacks
  • Add integration testing

Testing Instructions

  • Insert a media element
  • Double click on the element
  • Resize the crop window to be smaller than the original element
  • Use keyboard arrows to move the original element
  • Press tab or click on the image size slider to focus it
  • Press left-right arrow keys to change size
  • Press image again (or press shift+tab) to return focus to image
  • Press keyboard arrows to move the original element

Fixes #682

@codecov
Copy link

codecov bot commented May 29, 2020

Codecov Report

Merging #2108 into main will increase coverage by 0.48%.
The diff coverage is 92.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2108      +/-   ##
==========================================
+ Coverage   82.87%   83.35%   +0.48%     
==========================================
  Files         830      831       +1     
  Lines       14498    14521      +23     
==========================================
+ Hits        12015    12104      +89     
+ Misses       2483     2417      -66     
Flag Coverage Δ
#karmatests 71.40% <92.10%> (+0.62%) ⬆️
#unittests 66.09% <13.15%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../src/edit-story/components/canvas/useCanvasKeys.js 77.04% <80.00%> (-3.55%) ⬇️
...s/src/edit-story/elements/media/editPanMoveable.js 88.57% <85.71%> (+84.40%) ⬆️
assets/src/edit-story/elements/media/edit.js 100.00% <100.00%> (+71.42%) ⬆️
assets/src/edit-story/elements/media/scalePanel.js 100.00% <100.00%> (+56.25%) ⬆️
assets/src/edit-story/utils/getKeyboardMovement.js 100.00% <100.00%> (ø)
assets/src/edit-story/elements/shared/index.js 100.00% <0.00%> (+4.16%) ⬆️
...ets/src/edit-story/app/media/pagination/reducer.js 50.00% <0.00%> (+5.00%) ⬆️
assets/src/edit-story/utils/useDoubleClick.js 96.00% <0.00%> (+8.00%) ⬆️
assets/src/edit-story/elements/media/index.js 100.00% <0.00%> (+9.09%) ⬆️
... and 7 more

@github-actions
Copy link
Contributor

github-actions bot commented May 29, 2020

Size Change: +490 B (0%)

Total Size: 1.19 MB

Filename Size Change
assets/js/edit-story.js 490 kB +207 B (0%)
assets/js/stories-dashboard.js 537 kB +283 B (0%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 268 B 0 B
assets/css/stories-dashboard.css 305 B 0 B
assets/css/web-stories-embed-block.css 515 B 0 B
assets/js/chunk-web-stories-template-0-********************.js 10.2 kB 0 B
assets/js/chunk-web-stories-template-1-********************.js 10.3 kB 0 B
assets/js/chunk-web-stories-template-2-********************.js 10 kB 0 B
assets/js/chunk-web-stories-template-3-********************.js 10.5 kB 0 B
assets/js/chunk-web-stories-template-4-********************.js 10.6 kB 0 B
assets/js/chunk-web-stories-template-5-********************.js 6.86 kB 0 B
assets/js/chunk-web-stories-template-6-********************.js 9.91 kB 0 B
assets/js/chunk-web-stories-template-7-********************.js 9.78 kB 0 B
assets/js/web-stories-activation-notice.js 63.6 kB 0 B
assets/js/web-stories-embed-block.js 16.9 kB 0 B

compressed-size-action

@barklund
Copy link
Contributor

So this PR fixes #1426 or?

And why is #1426 closed as a duplicate of itself by the way? 😮

@swissspidy swissspidy added the Status: Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 15, 2020
# Conflicts:
#	assets/src/edit-story/components/canvas/canvasProvider.js
#	assets/src/edit-story/components/canvas/framesLayer.js
#	assets/src/edit-story/elements/media/editPanMoveable.js
@google-cla
Copy link

google-cla bot commented Aug 19, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Aug 19, 2020
@barklund
Copy link
Contributor

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Aug 19, 2020
@barklund barklund removed the Status: Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 19, 2020
@barklund barklund marked this pull request as ready for review August 20, 2020 02:54
@barklund barklund requested review from miina and merapi August 20, 2020 02:54
@miina
Copy link
Contributor

miina commented Aug 20, 2020

From testing:

  • Otherwise works great, just one detail: there doesn't seem to be a visual difference if the keyboard focus is on the image or not -- e.g. using Tab to move to the slider and then back to the image doesn't make a visual difference for the image outline. Perhaps that can be deferred to the future though.

@miina
Copy link
Contributor

miina commented Aug 20, 2020

One more from testing:
While in edit mode and focusing away, e.g. clicking somewhere on the design panel, and then using arrow keys, the whole element is moved up/down even though it's in the edit mode. Should in edit mode the panned image move instead of the whole element?

element

@merapi
Copy link
Contributor

merapi commented Aug 20, 2020

@barklund @miina Can you confirm this issue on Safari?
When you enter the edit mode and press TAB it should focus on the slider but it doesn't work for me (I can also end up in a state where arrows move the thole element with edit mode).

}
const panFocalX = getFocalFromOffset(width, mediaWidth, offsetX - dx);
const panFocalY = getFocalFromOffset(height, mediaHeight, offsetY - dy);
setProperties({
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to lag currently when not clicking the keys slowly -- would be good to create a follow-up issue for looking into that.

Copy link
Contributor

@barklund barklund Aug 20, 2020

Choose a reason for hiding this comment

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

Yeah, there's a lot of lag currently. It's beginning to be a problem 😢

@miina
Copy link
Contributor

miina commented Aug 20, 2020

When you enter the edit mode and press TAB it should focus on the slider but it doesn't work for me

@merapi Confirmed -- indeed that focuses on the design panel items instead.

@swissspidy swissspidy added Accessibility Changes that impact accessibility and need corresponding review (e.g. markup changes). Elements: Image Elements: Video Group: Media Type: Enhancement New feature or improvement of an existing feature labels Aug 20, 2020
@barklund barklund self-assigned this Aug 20, 2020
@barklund
Copy link
Contributor

@miina, @merapi, I addressed your comments inline. Please see these two threads on disabling moving editmode elements at all and focus management.

@barklund barklund requested a review from miina August 20, 2020 16:08
Copy link
Contributor

@miina miina left a comment

Choose a reason for hiding this comment

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

Unit tests are failing currently, otherwise LGTM (let's create a performance-related follow-up issue, too).

@barklund barklund assigned csossi and unassigned csossi Aug 20, 2020
@merapi
Copy link
Contributor

merapi commented Aug 21, 2020

Oh, and regarding the fact that in Safari you cannot tab from the image to the slider, that is due to Safari's default of not actually using tab to navigate elements. You have to enable that in settings (which I assume all keyboard-using Safari users do):

Screen Shot 2020-08-20 at 11 56 03

Ok, that works, how about this one? (maybe it will surface in other places):
on every other browser when you change the zoom (via mouse), the slider becomes focused (blue), on Safari - it's not (you can't adjust zoom via keyboard after that).

@barklund barklund merged commit f805c1e into main Aug 31, 2020
@barklund barklund deleted the image-editor/keyboard-nav branch August 31, 2020 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Changes that impact accessibility and need corresponding review (e.g. markup changes). Elements: Image Elements: Video Group: Media Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard Nav when Editing Masked Image
8 participants