Improve accessibility when (re-)viewing files (#24817)

Visually, nothing should have changed.
Changes include
- Convert most `<a [no href]>` to `<button>` when (re-)viewing files:
- `<a [no href]>` are, by HTML definition, not a link and hence cannot
be focused
- `<a class="ui button">` can now be clicked (again?) using
<kbd>Enter</kbd>
- Previously, the installed keypress handler on `.ui.button` elements
disabled it for links somehow
- The `(un)escape file`, the `expand section` and the `expand/collapse
file` buttons can now be focused (and subsequently clicked using only
the keyboard)
- You can now press <kbd>Space</kbd> on a focused `View file` checkbox
to mark the file as viewed.
- previously, this was impossible as this checkbox listened on the wrong
event listener

The `add code comment` button has been left inaccessible for now as it
requires quite a bit of extra logic so that it is unhidden when it is
focused (you can otherwise focus it without seeing it as you are not
hovering on the corresponding line).

---------

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
delvh
2023-05-21 22:47:41 +02:00
committed by GitHub
parent c59a057297
commit e95b42e187
17 changed files with 105 additions and 92 deletions

View File

@ -2943,7 +2943,7 @@ tbody.commit-list {
padding-top: 0 !important;
}
td.blob-excerpt {
.blob-excerpt {
background-color: var(--color-secondary-alpha-30);
}

View File

@ -21,7 +21,7 @@
transform: scale(1.1);
}
.lines-escape a.toggle-escape-button::before {
.lines-escape .toggle-escape-button::before {
visibility: visible;
content: "⚠️";
font-family: var(--fonts-emoji);
@ -198,7 +198,8 @@
color: var(--color-text);
}
a.blob-excerpt {
.code-expander-button {
border: none;
color: var(--color-text-light);
height: 28px;
display: flex;
@ -206,9 +207,10 @@ a.blob-excerpt {
align-items: center;
width: 100%;
background: var(--color-expand-button);
flex: 1;
}
a.blob-excerpt:hover {
.code-expander-button:hover {
background: var(--color-primary);
color: var(--color-primary-contrast);
}