You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
a11y: jump to main content doesn't work without JS #6411
changed the title [-]Make website accessible in a graphical browser[/-][+]a11y: jump to main content doesn't work without JS, links don't have focus outline[/+]on Jan 24, 2022
changed the title [-]a11y: jump to main content doesn't work without JS, links don't have focus outline[/-][+]a11y: without JS, jump to main content doesn't work, links don't have focus outline[/+]on Jan 24, 2022
The outline is moved to JS logic in #3626. Apparently, the fix here would be to use :focus-visible, but until this point, it's not supported in Safari. (Although Safari has terrible support of tabbing anyways)
@locriacyber was wondering, why would someone needing accessibility aid use a website without JavaScript? I was discussing this with some other front-end developers, and seems the consensus is that JavaScript is necessary for a lot of a11y features, unless you rely on experimental WCAG features. a11y and browser compatibility—we have to make a compromise.
changed the title [-]a11y: without JS, jump to main content doesn't work, links don't have focus outline[/-][+]a11y: jump to main content doesn't work without JS[/+]on Feb 13, 2022
@lex111 Wonder what's your idea on this issue? Should we use programmatic focus, or should we simply use a link to an element ID? Other sites I researched (like NYT and GitHub) seem to use an anchor link. GitHub would instantly erase the hash from the location if JS is enabled.
Initially I didn't add explicit identifiers to try to make the STC button as workable as possible on any page. You could try to add identifiers that are resolves this issue, but why would anyone use a site with disabled JS, I still don't get it?
Me neither 😅 Apparently there would always be a11y features that are only available with JS, but this one seems solvable without JS, and other sites seem to handle it without JS. About "workable on any page", we currently focus to .main-wrapper, so if we simply add id="main" to the same div, it should work just the same, right?
@Josh-Cena@slorber I would like to pick up this issue, but have a few clarifying questions:
Shall the existing JS focus be dumped entirely in favor of a simple anchor? (IMHO using native href is always preferred compared to JS so this is a good direction).
useId hook cannot be used because the root docusaurus package (main package.json) depends on React 17 and theme-classic has also peer dep only 16.8 or 17. UseId is however only available since 18.
I am not sure why the dynamic useId hook is necessary anyway. When looking at the documentation, it seems like the id shall be added to Layout > mainWrapper div and since I assume every page will always have at most 1 Layout, then static ID shall be enough. Please correct me if I am missing something.
our current skipToContent behavior focuses in priority an existing <main> tag over an explicit id/className
we are keeping this behavior (for now)
we are introducing an explicit "id" (instead of a className) that is used more as a "fallback" in case no <main> tag exists. In this case, focusing on the <Layout> children container is reasonable behavior.
when JS is disabled, it's not possible to replicate the same behavior (<main> used in priority). Afaik it's not possible to have a link target a <main> element that may not have an id
For some pages, like the docs, it leads to slightly different behaviors with/without JS.
With JS: the document markdown content gets focused on first tab (<main>):
Without JS: the docs sidebar get focused on first tab (layout children, fallback behavior)
That is likely not a big deal.
For now, I'd rather avoid changing the historical JS behavior ("focus main in priority") for retro compatibility. The noJS behavior we are introducing in #8204 is probably a good enough improvement already.
Activity
iacore commentedon Jan 19, 2022
Discovered in tauri-apps/tauri-docs#307
Josh-Cena commentedon Jan 20, 2022
Will be fixed by #5822
The others are valid issues. Thanks for reporting.
[-]Make website accessible in a graphical browser[/-][+]a11y: jump to main content doesn't work without JS, links don't have focus outline[/+][-]a11y: jump to main content doesn't work without JS, links don't have focus outline[/-][+]a11y: without JS, jump to main content doesn't work, links don't have focus outline[/+]iacore commentedon Jan 27, 2022
Only the linked color contrast is fixed by #5822 (Used the link preview https://deploy-preview-5822--docusaurus-2.netlify.app/docs/styling-layout/)
Josh-Cena commentedon Jan 27, 2022
Indeed, my message says that only the quoted problem will be fixed😆 Maybe I didn't make it clear enough...
Josh-Cena commentedon Jan 29, 2022
The outline is moved to JS logic in #3626. Apparently, the fix here would be to use
:focus-visible, but until this point, it's not supported in Safari. (Although Safari has terrible support of tabbing anyways)@locriacyber was wondering, why would someone needing accessibility aid use a website without JavaScript? I was discussing this with some other front-end developers, and seems the consensus is that JavaScript is necessary for a lot of a11y features, unless you rely on experimental WCAG features. a11y and browser compatibility—we have to make a compromise.
slorber commentedon Feb 3, 2022
We fixed the focus outline normally @locriacyber , please let us know if it doesn't work
We'll keep this issue open for the remaining fixes.
iacore commentedon Feb 3, 2022
It's a separate issue. The browser default is to underline links when focused. This feature only needs CSS.
The outline is visible now.
[-]a11y: without JS, jump to main content doesn't work, links don't have focus outline[/-][+]a11y: jump to main content doesn't work without JS[/+]Josh-Cena commentedon Mar 31, 2022
@lex111 Wonder what's your idea on this issue? Should we use programmatic focus, or should we simply use a link to an element ID? Other sites I researched (like NYT and GitHub) seem to use an anchor link. GitHub would instantly erase the hash from the location if JS is enabled.
lex111 commentedon Mar 31, 2022
Initially I didn't add explicit identifiers to try to make the STC button as workable as possible on any page. You could try to add identifiers that are resolves this issue, but why would anyone use a site with disabled JS, I still don't get it?
Josh-Cena commentedon Mar 31, 2022
Me neither 😅 Apparently there would always be a11y features that are only available with JS, but this one seems solvable without JS, and other sites seem to handle it without JS. About "workable on any page", we currently focus to
.main-wrapper, so if we simply addid="main"to the same div, it should work just the same, right?lex111 commentedon Mar 31, 2022
Not so sure about that, but most likely yes.
iacore commentedon Apr 1, 2022
id="main-45678987654345"is betterJosh-Cena commentedon Apr 1, 2022
React 18 has a
useIdhook, I think we can use that.mturoci commentedon Oct 10, 2022
@Josh-Cena @slorber I would like to pick up this issue, but have a few clarifying questions:
useIdhook cannot be used because the root docusaurus package (main package.json) depends on React 17 and theme-classic has also peer dep only 16.8 or 17.UseIdis however only available since 18.useIdhook is necessary anyway. When looking at the documentation, it seems like the id shall be added to Layout > mainWrapper div and since I assume every page will always have at most 1 Layout, then static ID shall be enough. Please correct me if I am missing something.fix(theme-classic): Use native href for skip to content meta#6411.
slorber commentedon Oct 19, 2022
Something to consider:
<main>tag over an explicit id/className<main>tag exists. In this case, focusing on the<Layout>children container is reasonable behavior.<main>used in priority). Afaik it's not possible to have a link target a<main>element that may not have an idFor some pages, like the docs, it leads to slightly different behaviors with/without JS.
Test page: https://deploy-preview-8204--docusaurus-2.netlify.app/docs/
With JS: the document markdown content gets focused on first tab (
<main>):Without JS: the docs sidebar get focused on first tab (layout children, fallback behavior)
That is likely not a big deal.
For now, I'd rather avoid changing the historical JS behavior ("focus main in priority") for retro compatibility. The noJS behavior we are introducing in #8204 is probably a good enough improvement already.