Skip to content

Commit c2bc95d

Browse files
authored
Merge pull request #143 from WebCoder49/accessible-close-buttons
Make FindAndReplace and GoToLine close buttons screenreader accessible; fix typo in tester file
2 parents f024f1b + 1db035c commit c2bc95d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

plugins/find-and-replace.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ codeInput.plugins.FindAndReplace = class extends codeInput.Plugin {
204204
const findPreviousButton = document.createElement('button');
205205
const replaceButton = document.createElement('button');
206206
const replaceAllButton = document.createElement('button');
207+
208+
// TODO: Make a button element (semantic HTML for accessibility) in next major version
207209
const cancel = document.createElement('span');
210+
cancel.setAttribute("role", "button");
211+
cancel.setAttribute("aria-label", this.instructions.closeDialog);
208212
cancel.setAttribute("tabindex", 0); // Visible to keyboard navigation
209213
cancel.setAttribute("title", this.instructions.closeDialog);
210214

@@ -243,8 +247,10 @@ codeInput.plugins.FindAndReplace = class extends codeInput.Plugin {
243247
replaceInput.placeholder = this.instructions.replacePlaceholder;
244248
findNextButton.innerText = "↓";
245249
findNextButton.title = this.instructions.findNext;
250+
findNextButton.setAttribute("aria-label", this.instructions.findNext);
246251
findPreviousButton.innerText = "↑";
247252
findPreviousButton.title = this.instructions.findPrevious;
253+
findNextButton.setAttribute("aria-label", this.instructions.findPrevious);
248254
replaceButton.className = 'code-input_find-and-replace_button-hidden';
249255
replaceButton.innerText = this.instructions.replaceActionShort;
250256
replaceButton.title = this.instructions.replaceAction;

plugins/go-to-line.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ codeInput.plugins.GoToLine = class extends codeInput.Plugin {
9090

9191
const dialog = document.createElement('div');
9292
const input = document.createElement('input');
93+
94+
// TODO: Make a button element (semantic HTML for accessibility) in next major version
9395
const cancel = document.createElement('span');
96+
cancel.setAttribute("role", "button");
97+
cancel.setAttribute("aria-label", this.instructions.closeDialog);
9498
cancel.setAttribute("tabindex", 0); // Visible to keyboard navigation
9599
cancel.setAttribute("title", this.instructions.closeDialog);
96100

tests/tester.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ console.log("I've got another line!", 2 < 3, "should be true.");
533533
addText(textarea, `function printTriples(max) {\nfor(let i = 0; i < max-2; i++) {\nfor(let j = 0; j < max-1; j++) {\nfor(let k = 0; k < max; k++) {\nconsole.log(i,j,k);\n}\n//Hmmm...\n}//Test auto-unindent\n{`, true);
534534
move(textarea, 1); // Move after created closing bracket
535535
backspace(textarea); // Remove created closing bracket
536-
}, 'function printTriples(max) {\n for(let i = 0; i < max-2; i++) {\n for(let j = 0; j < max-1; j++) {\n for(let k = 0; k < max; k++) {\n console.log(i,j,k);\n }\n //Hmmm...\n }//Test auto-unindent\n {\n }\n }\n }\n}', 221, 211);
536+
}, 'function printTriples(max) {\n for(let i = 0; i < max-2; i++) {\n for(let j = 0; j < max-1; j++) {\n for(let k = 0; k < max; k++) {\n console.log(i,j,k);\n }\n //Hmmm...\n }//Test auto-unindent\n {\n }\n }\n }\n}', 221, 221);
537537

538538
// SelectTokenCallbacks
539539
if(isHLJS) {

0 commit comments

Comments
 (0)