Improves accessibility for QA features (#1863)

- Switches from spans with classes to `ins` and `del` tags for text
comparison
- Adds `aria-label` attributes for screen readers. Text comparison is
accessible now! 🎉
- I kept the strikethrough text on the `del` tag but can remove? Only
visible on hover.
- Removes autofocus on the delete analysis run cancel button
- Adds `aria-label` attribute for the heuristic nav bar to describe the
context of the content users will be seeing on each page.
This commit is contained in:
Henry Wilkinson 2024-06-12 21:32:43 -04:00 committed by GitHub
parent f8cde4bd76
commit dc9069d1bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 20 deletions

View File

@ -425,7 +425,6 @@ export class ArchivedItemDetailQA extends TailwindElement {
<div slot="footer" class="flex justify-between"> <div slot="footer" class="flex justify-between">
<sl-button <sl-button
size="small" size="small"
.autofocus=${true}
@click=${() => void this.deleteQADialog?.hide()} @click=${() => void this.deleteQADialog?.hide()}
> >
${msg("Cancel")} ${msg("Cancel")}

View File

@ -508,6 +508,7 @@ export class ArchivedItemQA extends TailwindElement {
<div class="grid--tabGroup flex min-w-0 flex-col"> <div class="grid--tabGroup flex min-w-0 flex-col">
<nav <nav
aria-label="${msg("Page heuristics")}"
class="-mx-3 my-0 flex gap-2 overflow-x-auto px-3 py-2 lg:mx-0 lg:px-0" class="-mx-3 my-0 flex gap-2 overflow-x-auto px-3 py-2 lg:mx-0 lg:px-0"
> >
<btrix-navigation-button <btrix-navigation-button

View File

@ -20,7 +20,7 @@ function renderDiff(
diffImport.then(({ diffWords }) => { diffImport.then(({ diffWords }) => {
const diff = diffWords(crawlText, qaText); const diff = diffWords(crawlText, qaText);
const addedText = tw`bg-red-100 text-red-700`; const addedText = tw`bg-red-100 text-red-700 no-underline`;
const removedText = tw`bg-red-100 text-red-100`; const removedText = tw`bg-red-100 text-red-100`;
return html` return html`
@ -29,16 +29,23 @@ function renderDiff(
aria-labelledby="crawlTextHeading" aria-labelledby="crawlTextHeading"
> >
${diff.map((part) => { ${diff.map((part) => {
return html` if (part.added) {
<span return html`<del
class=${part.added aria-label="${msg("Missing text: Crawl")}"
? removedText class="${removedText}"
: part.removed >${part.value}</del
? addedText >`;
: ""} } else if (part.removed) {
return html`<ins
aria-label="${msg("Added text: Crawl")}"
class="${addedText}"
>${part.value}</ins
>`;
} else {
return html`<span aria-label="${msg("Identical text")}"
>${part.value}</span >${part.value}</span
> >`;
`; }
})} })}
</div> </div>
<div <div
@ -46,16 +53,23 @@ function renderDiff(
aria-labelledby="qaTextHeading" aria-labelledby="qaTextHeading"
> >
${diff.map((part) => { ${diff.map((part) => {
return html` if (part.added) {
<span return html`<ins
class=${part.added aria-label="${msg("Added text: Analysis")}"
? addedText class="${addedText}"
: part.removed >${part.value}</ins
? removedText >`;
: ""} } else if (part.removed) {
return html`<del
aria-label="${msg("Missing text: Analysis")}"
class="${removedText}"
>${part.value}</del
>`;
} else {
return html`<span aria-label="${msg("Identical text")}"
>${part.value}</span >${part.value}</span
> >`;
`; }
})} })}
</div> </div>
`; `;