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:
parent
c59a057297
commit
e95b42e187
17 changed files with 105 additions and 92 deletions
|
@ -2,30 +2,30 @@ import $ from 'jquery';
|
|||
import {hideElem, showElem} from '../utils/dom.js';
|
||||
|
||||
export function initUnicodeEscapeButton() {
|
||||
$(document).on('click', 'a.escape-button', (e) => {
|
||||
$(document).on('click', '.escape-button', (e) => {
|
||||
e.preventDefault();
|
||||
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').addClass('unicode-escaped');
|
||||
hideElem($(e.target));
|
||||
showElem($(e.target).siblings('a.unescape-button'));
|
||||
showElem($(e.target).siblings('.unescape-button'));
|
||||
});
|
||||
$(document).on('click', 'a.unescape-button', (e) => {
|
||||
$(document).on('click', '.unescape-button', (e) => {
|
||||
e.preventDefault();
|
||||
$(e.target).parents('.file-content, .non-diff-file-content').find('.file-code, .file-view').removeClass('unicode-escaped');
|
||||
hideElem($(e.target));
|
||||
showElem($(e.target).siblings('a.escape-button'));
|
||||
showElem($(e.target).siblings('.escape-button'));
|
||||
});
|
||||
$(document).on('click', 'a.toggle-escape-button', (e) => {
|
||||
$(document).on('click', '.toggle-escape-button', (e) => {
|
||||
e.preventDefault();
|
||||
const fileContent = $(e.target).parents('.file-content, .non-diff-file-content');
|
||||
const fileView = fileContent.find('.file-code, .file-view');
|
||||
if (fileView.hasClass('unicode-escaped')) {
|
||||
fileView.removeClass('unicode-escaped');
|
||||
hideElem(fileContent.find('a.unescape-button'));
|
||||
showElem(fileContent.find('a.escape-button'));
|
||||
hideElem(fileContent.find('.unescape-button'));
|
||||
showElem(fileContent.find('.escape-button'));
|
||||
} else {
|
||||
fileView.addClass('unicode-escaped');
|
||||
showElem(fileContent.find('a.unescape-button'));
|
||||
hideElem(fileContent.find('a.escape-button'));
|
||||
showElem(fileContent.find('.unescape-button'));
|
||||
hideElem(fileContent.find('.escape-button'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue