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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
097b633
add gutter keyboard handler
akoreman Apr 27, 2023
e22f066
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman Apr 27, 2023
86c34de
fixes
akoreman Apr 27, 2023
53b752f
Merge branch 'keyboard_gutter' of https://github.com/akoreman/ace int…
akoreman Apr 27, 2023
de509b6
improve handling number of edge-cases
akoreman Apr 27, 2023
ed20e41
add scrolling if cursor outside viewport
akoreman Apr 27, 2023
c1aa747
add annotation control
akoreman Apr 27, 2023
6fa7132
refactor gutter tooltip
akoreman Apr 27, 2023
e0b78ad
correctly set annotation tooltip position
akoreman Apr 28, 2023
d6a9555
refactoring
akoreman Apr 28, 2023
277b3bd
more refactoring
akoreman Apr 28, 2023
8aaf737
add/remove semi-colons
akoreman Apr 28, 2023
7d0ad22
refactor to pass eslint
akoreman Apr 28, 2023
bca6730
fix edge case
akoreman Apr 28, 2023
d48b49d
refactor
akoreman Apr 28, 2023
0f89839
fix edge case
akoreman Apr 28, 2023
f484162
add support folded annotation
akoreman Apr 28, 2023
14d4f7c
read active row on focus
akoreman Apr 29, 2023
06a53f0
refactor
akoreman Apr 29, 2023
7d93299
aria label unfold line
akoreman Apr 29, 2023
e490059
hande more edge cases
akoreman Apr 29, 2023
1fec596
style fix
akoreman Apr 29, 2023
42d5484
add end row unfold aria label
akoreman Apr 29, 2023
393b3de
refactor
akoreman Apr 30, 2023
329b118
fix typo
akoreman Apr 30, 2023
5b5e6b4
add basic test
akoreman Apr 30, 2023
b41bc04
add KeyboardEvent to eslint globals
akoreman Apr 30, 2023
e5b9e38
tweak fold test
akoreman May 1, 2023
6364be5
fix comma dangle
akoreman May 1, 2023
e39e58d
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman May 1, 2023
df94c8b
add multiple annotation test
akoreman May 1, 2023
85b7c27
add multi fold test
akoreman May 1, 2023
8f5bf05
add tests
akoreman May 1, 2023
17e1d84
extend multi icon test
akoreman May 1, 2023
814ae0b
refactoring + style
akoreman May 1, 2023
74d26b4
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman May 1, 2023
fab6d43
refactor
akoreman May 1, 2023
17825ed
renaming
akoreman May 1, 2023
6fcfd17
add focus outline SVG icons
akoreman May 2, 2023
031ee05
fix css
akoreman May 2, 2023
9c9621e
fix failing test
akoreman May 2, 2023
7a0d35f
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman May 2, 2023
d3c73de
fix edge case
akoreman May 2, 2023
8b2850a
refactor
akoreman May 2, 2023
b3ef448
simplify logic
akoreman May 2, 2023
f3e07d7
fix test
akoreman May 2, 2023
e503b12
refactor
akoreman May 2, 2023
05bd7a9
cleanup
akoreman May 2, 2023
c779796
more cleanup
akoreman May 2, 2023
7610d62
fix test
akoreman May 2, 2023
94b5948
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman May 3, 2023
a50f2b1
hide tooltip on gutter blur
akoreman May 3, 2023
2e5917c
cleanup
akoreman May 3, 2023
1c9606f
Merge branch 'ajaxorg:master' into keyboard_gutter
akoreman May 3, 2023
abfa429
improve finding active row
akoreman May 3, 2023
1cef515
only move to fully visible icons
akoreman May 4, 2023
0b64a95
change how a11y props are removed
akoreman May 4, 2023
97686b0
fix scroll bug
akoreman May 4, 2023
25dd3c3
improve behaviour end of doc
akoreman May 4, 2023
029f9e4
cleanup
akoreman May 4, 2023
fdb1355
blur keyboard gutter on mouse wheel
akoreman May 4, 2023
00dddb0
fix typo
akoreman May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
prompt: true,
XMLHttpRequest: true,
localStorage: true,
KeyboardEvent: true,
},
"rules": {
curly: 0,
Expand Down
6 changes: 3 additions & 3 deletions src/css/editor.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ module.exports = `
background-repeat: no-repeat;
}

.ace_gutter-cell_svg-icons .ace_icon_svg {
.ace_gutter-cell_svg-icons .ace_gutter_annotation {
margin-left: -14px;
float: left;
}

.ace_gutter-cell .ace_icon {
margin-left: -18px;
.ace_gutter-cell .ace_gutter_annotation {
margin-left: -19px;
float: left;
}

Expand Down
5 changes: 4 additions & 1 deletion src/edit_session/folding.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var Range = require("../range").Range;
var FoldLine = require("./fold_line").FoldLine;
var Fold = require("./fold").Fold;
var TokenIterator = require("../token_iterator").TokenIterator;
var MouseEvent = require("../mouse/mouse_event").MouseEvent;

function Folding() {
/*
Expand Down Expand Up @@ -755,7 +756,9 @@ function Folding() {
};

this.onFoldWidgetClick = function(row, e) {
e = e.domEvent;
if (e instanceof MouseEvent)
e = e.domEvent;

var options = {
children: e.shiftKey,
all: e.ctrlKey || e.metaKey,
Expand Down
47 changes: 41 additions & 6 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
var config = require("./config");
var TokenIterator = require("./token_iterator").TokenIterator;
var LineWidgets = require("./line_widgets").LineWidgets;
var GutterKeyboardHandler = require("./keyboard/gutter_handler").GutterKeyboardHandler;

var clipboard = require("./clipboard");
var keys = require('./lib/keys');
Expand Down Expand Up @@ -2874,34 +2875,68 @@

var focusOnEnterKeyup = function (e) {
if (e.target == this.renderer.content && e.keyCode === keys['enter']){
e.stopPropagation();
e.preventDefault();
var row = this.getCursorPosition().row;

Check warning on line 2879 in src/editor.js

View check run for this annotation

Codecov / codecov/patch

src/editor.js#L2879

Added line #L2879 was not covered by tests

if (!this.isRowVisible(row))
this.scrollToLine(row, true, true);

Check warning on line 2882 in src/editor.js

View check run for this annotation

Codecov / codecov/patch

src/editor.js#L2881-L2882

Added lines #L2881 - L2882 were not covered by tests

this.focus();
}
};

var keyboardFocusClassName = "ace_keyboard-focus";
var gutterKeyboardHandler;

// Prevent focus to be captured when tabbing through the page. When focus is set to the content div,
// press Enter key to give focus to Ace and press Esc to again allow to tab through the page.
if (value){
this.keyboardFocusClassName = "ace_keyboard-focus";

this.textInput.getElement().setAttribute("tabindex", -1);
this.renderer.content.setAttribute("tabindex", 0);
this.renderer.content.classList.add(keyboardFocusClassName);
this.renderer.content.setAttribute("role", "group");
this.renderer.content.setAttribute("aria-roledescription", "editor");
this.renderer.content.classList.add(this.keyboardFocusClassName);
this.renderer.content.setAttribute("aria-label",
"Editor, press Enter key to start editing, press Escape key to exit"
"Editor content, press Enter to start editing, press Escape to exit"
);

this.renderer.content.addEventListener("keyup", focusOnEnterKeyup.bind(this));
this.commands.addCommand(blurCommand);

this.renderer.$gutter.setAttribute("tabindex", 0);
this.renderer.$gutter.setAttribute("aria-hidden", false);
this.renderer.$gutter.setAttribute("role", "group");
this.renderer.$gutter.setAttribute("aria-roledescription", "editor");
this.renderer.$gutter.setAttribute("aria-label",
"Editor gutter, press Enter to interact with controls using arrow keys, press Escape to exit"
);
this.renderer.$gutter.classList.add(this.keyboardFocusClassName);

if (!gutterKeyboardHandler)
gutterKeyboardHandler = new GutterKeyboardHandler(this);

gutterKeyboardHandler.addListener();
} else {
this.textInput.getElement().setAttribute("tabindex", 0);
this.renderer.content.setAttribute("tabindex", -1);
this.renderer.content.classList.remove(keyboardFocusClassName);
this.renderer.content.setAttribute("aria-label", "");
this.renderer.content.removeAttribute("role");
this.renderer.content.removeAttribute("aria-roledescription");
this.renderer.content.classList.remove(this.keyboardFocusClassName);
this.renderer.content.removeAttribute("aria-label");

this.renderer.content.removeEventListener("keyup", focusOnEnterKeyup.bind(this));
this.commands.removeCommand(blurCommand);

this.renderer.$gutter.setAttribute("tabindex", -1);
this.renderer.$gutter.setAttribute("aria-hidden", true);
this.renderer.$gutter.removeAttribute("role");
this.renderer.$gutter.removeAttribute("aria-roledescription");
this.renderer.$gutter.removeAttribute("aria-label");
this.renderer.$gutter.classList.remove(this.keyboardFocusClassName);

if (gutterKeyboardHandler)
gutterKeyboardHandler.removeListener();

Check warning on line 2939 in src/editor.js

View check run for this annotation

Codecov / codecov/patch

src/editor.js#L2939

Added line #L2939 was not covered by tests
}
},
initialValue: false
Expand Down