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

Accessibility - Notify keyboard/screen reader user how to exit input field #1741

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/web/Manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Manager {
document.getElementById("btn-new-tab").addEventListener("click", this.input.addInputClick.bind(this.input));
document.getElementById("btn-previous-input-tab").addEventListener("mousedown", this.input.previousTabClick.bind(this.input));
document.getElementById("btn-next-input-tab").addEventListener("mousedown", this.input.nextTabClick.bind(this.input));
document.getElementById("input-text").addEventListener("keydown", this.input.tabNotification.bind(this.input), false);
this.addListeners("#btn-next-input-tab,#btn-previous-input-tab", "mouseup", this.input.tabMouseUp, this.input);
this.addListeners("#btn-next-input-tab,#btn-previous-input-tab", "mouseout", this.input.tabMouseUp, this.input);
document.getElementById("btn-go-to-input-tab").addEventListener("click", this.input.goToTab.bind(this.input));
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
<i class="material-icons">delete</i>
</button>
<button type="button" class="btn btn-primary bmd-btn-icon" id="reset-layout" data-toggle="tooltip" title="Reset pane layout" data-help-title="Resetting the pane layout" data-help="CyberChef's panes can be resized to suit your area of focus. This button will reset the pane sizes to their default configuration.">
<i class="material-icons">view_compact</i>
<i class="material-icons" aria-hidden='true'>view_compact</i>
</button>
</span>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/web/stylesheets/layout/_io.css
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@
filter: brightness(98%);
}

#visually-hidden-input-alert {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

/* Highlighting */
.ͼ2.cm-focused .cm-selectionBackground {
background-color: var(--hl5);
Expand Down
17 changes: 15 additions & 2 deletions src/web/waiters/InputWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class InputWaiter {
lineWrapping: new Compartment,
fileDetailsPanel: new Compartment
};

localStorage.setItem("alerted", "no");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe best to change this to this.alerted = 'no' as opposed to using local storage.

const initialState = EditorState.create({
doc: null,
extensions: [
Expand Down Expand Up @@ -141,7 +141,7 @@ class InputWaiter {
if (e.docChanged && !this.silentInputChange)
this.inputChange(e);
this.silentInputChange = false;
})
}),
]
});

Expand Down Expand Up @@ -186,7 +186,20 @@ class InputWaiter {
this.inputChrEnc = chrEncVal;
this.inputChange();
}
/**
* Handler for Tab key events within input
* Notifies keyboard/screen reader users how to navigate out of input field
* @param {event} event
*/
tabNotification(event) {
const alerted = localStorage.getItem("alerted") || "";

if (event.key === "Tab" && alerted !== "yes") {
this.app.alert("Press Escape then Tab to exit the input field.", 7000);
localStorage.setItem("alerted", "yes");
return $("#snackbar-container").append("<p role='alert' id='visually-hidden-input-alert'>Press Escape then Tab to exit the input field.</p>");
}
}
/**
* Getter for the input character encoding
* @returns {number}
Expand Down
Loading