Skip to content

Commit 8ceb8d3

Browse files
committed
a11y: Make 'Scroll to bottom' button accessible
Make sure a screen reader recognizes the button and can read a descriptive name. * add `aria-hidden` to the SVG element so it is igronred * add a `span` with a readable text * style the `span` to be invisible to eyes At first, it seems like we should have a better way to do this kind of accessibility, but this convoluted way of implementing it is indeed the best-practice.
1 parent cb44371 commit 8ceb8d3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/webview/css/css.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ blockquote {
414414
border-radius: 50%;
415415
background: rgba(82, 194, 175, 0.5);
416416
}
417+
#scroll-bottom .text {
418+
clip: rect(0 0 0 0);
419+
overflow: hidden;
420+
position: absolute;
421+
height: 1px;
422+
width: 1px;
423+
}
417424
#scroll-bottom svg {
418425
width: 32px;
419426
height: 32px;

src/webview/html/htmlScrollToBottom.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import template from './template';
33

44
export default template`
55
<div id="scroll-bottom" class="scroll-bottom hidden">
6-
<a href="" class="scroll-bottom">
7-
<svg class="scroll-bottom" width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
6+
<a href="" class="scroll-bottom" aria-hidden>
7+
<span class="text">Scroll to bottom</span>
8+
<svg class="scroll-bottom" width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg" aria-hidden>
89
<path class="scroll-bottom" d="M1395 736q0 13-10 23l-466 466q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l393 393 393-393q10-10 23-10t23 10l50 50q10 10 10 23z"/>
910
</svg>
1011
</a>

0 commit comments

Comments
 (0)