A11Y: Improve setting focus to post (#23243)

This commit is contained in:
Penar Musaraj 2023-08-25 14:45:56 -04:00 committed by GitHub
parent 058c8496f0
commit a94834abd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 19 deletions

View File

@ -803,7 +803,9 @@ export default {
}, },
_onScrollEndsCallback() { _onScrollEndsCallback() {
document.querySelector(".topic-post.selected span.tabLoc")?.focus(); document
.querySelector(".topic-post.selected a:not([tabindex='-1'])")
?.focus();
}, },
categoriesTopicsList() { categoriesTopicsList() {

View File

@ -77,7 +77,8 @@ export function highlightPost(postNumber) {
return; return;
} }
container.querySelector(".tabLoc")?.focus(); // sets focus to the first focusable anchor in the post
container.querySelector("a:not([tabindex='-1'])")?.focus();
const element = container.querySelector(".topic-body"); const element = container.querySelector(".topic-body");
if (!element || element.classList.contains("highlighted")) { if (!element || element.classList.contains("highlighted")) {

View File

@ -190,9 +190,6 @@ export default createWidget("post-small-action", {
} }
return [ return [
h("span.tabLoc", {
attributes: { "aria-hidden": true, tabindex: -1 },
}),
h("div.topic-avatar", iconNode(icons[attrs.actionCode] || "exclamation")), h("div.topic-avatar", iconNode(icons[attrs.actionCode] || "exclamation")),
h("div.small-action-desc", [ h("div.small-action-desc", [
h("div.small-action-contents", contents), h("div.small-action-contents", contents),

View File

@ -751,11 +751,7 @@ createWidget("post-article", {
}, },
html(attrs, state) { html(attrs, state) {
const rows = [ const rows = [];
h("span.tabLoc", {
attributes: { "aria-hidden": true, tabindex: -1 },
}),
];
if (state.repliesAbove.length) { if (state.repliesAbove.length) {
const replies = state.repliesAbove.map((p) => { const replies = state.repliesAbove.map((p) => {
return this.attach("embedded-post", p, { return this.attach("embedded-post", p, {

View File

@ -1170,11 +1170,6 @@ blockquote > *:last-child {
); );
min-width: 0; // Allows flex container to shrink min-width: 0; // Allows flex container to shrink
.avatar {
margin-right: 0.5em;
float: left;
}
p { p {
margin: 0; margin: 0;
padding: 0.15em 0.5em 0 0; padding: 0.15em 0.5em 0 0;
@ -1183,6 +1178,13 @@ blockquote > *:last-child {
.small-action-contents { .small-action-contents {
flex: 1 1 auto; flex: 1 1 auto;
display: flex;
a.trigger-user-card {
display: inline-flex;
align-items: center;
margin-right: 0.5em;
border-radius: 1em;
}
} }
.small-action-buttons { .small-action-buttons {

View File

@ -15,10 +15,6 @@
box-shadow: -3px 0 0 var(--danger); box-shadow: -3px 0 0 var(--danger);
} }
.tabLoc:focus {
outline: none;
}
.latest .featured-topic { .latest .featured-topic {
padding-left: 4px; padding-left: 4px;
} }