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 improvements #126

Merged
merged 9 commits into from
Apr 12, 2021
Merged

Accessibility improvements #126

merged 9 commits into from
Apr 12, 2021

Conversation

aomarks
Copy link
Member

@aomarks aomarks commented Apr 9, 2021

Live at https://polymerlabs.github.io/playground-elements/

  • Don't immediately enter edit mode when focusing the editor with Tab, because otherwise we're a Tab trap, because Tabs insert literal tabs. Instead, show a prompt to "Press Enter to start editing". Clicking into editable region with mouse works like before. Pressing Escape re-focuses the editor, allowing Tab to be used to focus next again.

  • Switch to CodeMirror's contenteditable input style. This makes it behave like a normal content editable region, so it's much better for screen readers (see https://codemirror.net/doc/manual.html#option_inputStyle -- it's the new default in CodeMirror 6 for this reason).

  • Mark line numbers with aria-hidden so that they don't get read aloud by screen readers (see VoiceOver speaks line numbers codemirror/codemirror5#6578).

@aomarks aomarks requested review from rictic and sorvell April 9, 2021 01:32
@aomarks aomarks force-pushed the a11y-1 branch 2 times, most recently from 2ddd555 to 0257d9a Compare April 9, 2021 15:50
@arthurevans
Copy link

arthurevans commented Apr 9, 2021

I'm seeing a really weird issue on this. When I hit space in the editor, it's taking me to the beginning of the line.
Edit: actually, it appears to be any character. The second character I type always jumps the cursor to the start of the current line.

codemirror/codemirror5#6651 fixes an issue when
CodeMirror is in a shadow root and using contenteditable mode. It's not yet
released, so temporarily depend on the git commit.

Note we generate and distribute our own CodeMirror build, so this is only
a devDependency so it won't cause any versioning issues for consumers.
@aomarks
Copy link
Member Author

aomarks commented Apr 10, 2021

I'm seeing a really weird issue on this. When I hit space in the editor, it's taking me to the beginning of the line.
Edit: actually, it appears to be any character. The second character I type always jumps the cursor to the start of the current line.

This turned out to be a CodeMirror + Shadow DOM compatibility bug. I've fixed it upstream in codemirror/codemirror5#6651, which is already merged. Since we generate our own CodeMirror build, for now I've just updated our devDependency to this git SHA so that we can use the fix right away.

@aomarks
Copy link
Member Author

aomarks commented Apr 12, 2021

Also got the aria-hidden=true fix merged upstream: codemirror/codemirror5#6652

@aomarks aomarks merged commit 897e552 into master Apr 12, 2021
@aomarks aomarks deleted the a11y-1 branch April 12, 2021 20:41
}

#keyboardHelp {
background: #00000099;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we get a little more line spacing and a little less left/right padding?

Copy link
Member Author

Choose a reason for hiding this comment

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

.CodeMirror {
height: 100% !important;
font-family: inherit !important;
border-radius: inherit;
}

#keyboardHelpScrim {
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdyt about some background shading here so that the help message is more obviously associated with the source editor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in #127

${this._showKeyboardHelp
? html`<div id="keyboardHelpScrim">
<p id="keyboardHelp">
Press Enter to start editing<br />Press Escape to exit editor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider styling on "Enter" and "Escape" to make them stand out a bit? Maybe bold or monospace?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in #127

augustjk pushed a commit to augustjk/playground-elements that referenced this pull request Jul 18, 2022
…irtualizer-directive

Apply fix from pull request google#120 to directive implementation
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.

4 participants