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

feat: Add gutter controls to keyboard accessibility mode #5146

Merged
merged 62 commits into from May 5, 2023

Conversation

akoreman
Copy link
Contributor

@akoreman akoreman commented Apr 28, 2023

Issue: #5125, #5145

Adds operating the fold controls and annotations in the gutter to the keyboard accessibility mode. When tabbing through the page, you can focus on the gutter div. When pressing enter, you enter the gutter and can use the arrow keys to navigate through the controls in the gutter. Press enter to interact with the controls. Press escape to set focus back to the gutter div and be able to TAB through the page again.

Only iterates over gutter controls in current viewbox to prevent potentially scrolling the cursor outside of the current view (which can cause a11y problems).

Screen.Recording.2023-05-03.at.14.03.50.mov

Additionally adds title attribute to folding buttons:

Screenshot 2023-05-01 200955

Screenshot 2023-05-01 201017

Changes to src/mouse/default_gutter_handler.js are moving things around to to it easier to use GutterTooltip outside of GutterMouseHandler.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@akoreman akoreman changed the title [WIP] Add gutter controls to keyboard accessibility mode [WIP] feat: Add gutter controls to keyboard accessibility mode Apr 28, 2023
@codecov
Copy link

codecov bot commented Apr 28, 2023

Codecov Report

Patch coverage: 93.61% and project coverage change: +0.09 🎉

Comparison is base (b6799c1) 86.84% compared to head (00dddb0) 86.94%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5146      +/-   ##
==========================================
+ Coverage   86.84%   86.94%   +0.09%     
==========================================
  Files         558      560       +2     
  Lines       43734    44220     +486     
  Branches     6793     6854      +61     
==========================================
+ Hits        37980    38446     +466     
- Misses       5754     5774      +20     
Flag Coverage Δ
unittests 86.94% <93.61%> (+0.09%) ⬆️

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

Impacted Files Coverage Δ
src/css/editor.css.js 100.00% <ø> (ø)
src/editor.js 80.14% <86.66%> (+0.28%) ⬆️
src/keyboard/gutter_handler.js 89.27% <89.27%> (ø)
src/mouse/default_gutter_handler.js 71.63% <96.77%> (+2.00%) ⬆️
src/layer/gutter.js 90.50% <97.22%> (+0.72%) ⬆️
src/keyboard/gutter_handler_test.js 99.36% <99.36%> (ø)
src/edit_session/folding.js 75.51% <100.00%> (+0.09%) ⬆️
src/keyboard/textinput.js 77.40% <100.00%> (+0.38%) ⬆️
src/layer/text.js 91.77% <100.00%> (+0.01%) ⬆️
src/mouse/default_gutter_handler_test.js 99.39% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@akoreman akoreman changed the title [WIP] feat: Add gutter controls to keyboard accessibility mode feat: Add gutter controls to keyboard accessibility mode May 2, 2023
@akoreman akoreman marked this pull request as ready for review May 3, 2023 12:22
@akoreman akoreman marked this pull request as draft May 3, 2023 13:50
@akoreman akoreman marked this pull request as ready for review May 3, 2023 19:12
src/editor.js Outdated

this.renderer.$gutter.setAttribute("tabindex", -1);
this.renderer.$gutter.setAttribute("aria-hidden", true);
this.renderer.content.setAttribute("role", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

What is a best approach for removing the aria attributes, is it set them to empty value or remove them completely. I guess I followed a different approach and asking to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there are differences between how assistive tech interpret it but it probably makes more sense to just remove the attributes. I'll update the PR.

}
}
};
this.setAriaLabel = function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we maybe merge two functions here: setAriaOptions and setAriaLabel? They seem serving similar purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we merge the functions, we'd need to make sure that whenever we call setAriaLabel we pass the same options as the last time we called setAriaOptions which I think would be a hassle given that e.g. autocomplete extensions also call this function.

return;
}

if (Math.abs(nearestAnnotationIndex - index) < Math.abs(nearestFoldIndex - index)){
Copy link
Contributor

Choose a reason for hiding this comment

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

if they are the same, nearestFoldIndex will get the keyboard focus, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, if there is both a fold widget and and an annotation on the nearest line, it defaults to the fold widget.

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

Successfully merging this pull request may close these issues.

None yet

2 participants