Problem/Motivation
Currently most (all) D8 themes 'Skip to content' link target the markup:
<a id="main-content" tabindex="-1"></a>
When we should be targeting something like:
<main id="main-content" role="main" tabindex="-1"></main>
This extra a tag that's missing an href attribute and textual content, isn't really needed and should be removed.
Steps to reproduce
Proposed resolution
TBD
Remaining tasks
Address follow up tag
Accessibility review
Change record
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #94 | drupal-n2784311-d10.1-94.patch | 4.19 KB | hitchshock |
| #61 | main-outline-firefox.png | 58.39 KB | chi |
| #58 | main-outline.png | 39.02 KB | chi |
| #48 | skip_to_main_content-2784311-48.patch | 2.65 KB | mgifford |
| #45 | skip_to_main_content-2784311-44.patch | 3.18 KB | mgifford |
Issue fork drupal-2784311
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2784311-11.x
changes, plain diff MR !4665
Comments
Comment #2
Jmdrawneek@googlemail.com commentedComment #3
Jmdrawneek@googlemail.com commentedComment #4
tim.plunkettThis was added in 2009, in #386462: Skip Navigation' should be in all core themes
AFAIK that was before the MAIN tag was in the official HTML spec, and using an A tag was the recommended approach.
That has changed since then, and an A tag is no longer preferred: http://webaim.org/techniques/skipnav/
See https://www.w3.org/TR/WCAG20/#navigation-mechanisms-skip for the official spec.
Comment #5
andrewmacpherson commentedThe
altattribute doesn't belong to<a>elements, only<area>, <img> and some <input> types.The
hrefattribute isn't mandatory for an<a>element when we use it in this way.I have no objection to the proposed change (in principal) but it must have manual testing in all the browsers we support to avoid a regression for keyboard operation.
Comment #6
Jmdrawneek@googlemail.com commentedComment #7
Jmdrawneek@googlemail.com commentedComment #8
Jmdrawneek@googlemail.com commentedYou're right @andrewmacpherson about the alt attribute, I'm clearly losing the plot. Writing javascript tests is clearly addled my brain.
Comment #9
Jmdrawneek@googlemail.com commentedComment #10
andrewmacpherson commentedThis should be fixed in the system module's copy of the page template first.
Tagging for Stable and Classy maintainer to consider. We avoid touching that markup unless there's a bug that really needs to be fixed. I'm not sure this qualifies, but @cottser can say otherwise.
Comment #11
andrewmacpherson commentedThe patch in #6 removes a documentation comment. I think we ought to keep that - it describes a relationship between two templates that isn't immediately obvious (there's a corresponding comment in
html.html.twig).Comment #12
andrewmacpherson commented@James: thanks for the patch! Can you make the change to the copy of page.html.twig in the system module instead? We should wait to see what the maintainers of stable + classy say about this, too.
Comment #13
andrewmacpherson commentedWe're not proposing a new class, removing
class="l-content"from the issue summary.Comment #14
Jmdrawneek@googlemail.com commentedComment #15
Jmdrawneek@googlemail.com commentedThat class was just an example and isn't in the patch.
Comment #16
andrewmacpherson commentedNo need to remain assigned while it needs review.
Comment #17
dman commentedMotivation is good, reasoning is good. Improvement is good. Removing Anorexic Anchors and linking to the *full* element being referred to (and not just a point at the top of it) is good.
Code is fine.
As the ID is being retained, and (AFAIK) all known browsers support the ID as a target, I can't see or imagine any regression issues.
I've run it through my memory of accessibility reviews and tests, including the keyboard shortcuts we expect to work and haven't been able to identify any possible issues.
The only medium UI change is that for text-to-speech-accessibility tools that highlight the current element that has been switched to, the highlight (eg, a thick orange box) flashes around the whole 'main' area ... instead of a little blob of orange before the heading. Overall, that's a change, but an improvement.
Comment #18
domosapiens commentedWhen you check your Drupal website using the Wave toolbar this also generates an error because the anchor is an 'empty link'.
The suggested patch also fix this wave toolbar error.
Comment #19
john cook commentedChanged to Reviewed & tested as it appears to have been by dman and DomoSpiens.
Comment #20
xjmThanks for the review and testing in #17 and #18. Sounds like the manual testing is covered and this does indeed resolve an accessibility bug.
The issue is still tagged "needs accessibility review" -- let's have one of the accessibility topic maintainers sign off for it to be RTBC. I've also left @Cottser a message to take a look at the patch. In terms of BC policy, I think it is okay for 8.3.x since it is making a change to a module template, which is allowed to change in minors, without changing one of the stable base themes.
Comment #21
star-szrPatch looks good, can be committed once we have approval from an accessibility topic maintainer.
I think it's too risky to change Stable or Classy templates for this.
Comment #22
andrewmacpherson commented@cottser: ah yes, thanks for the reminder. I tagged this back in comment #5.
Comment #23
andrewmacpherson commentedI am very close to signing off on this!
I've already done manual testing with LOTS of desktop OS/browsers (+ screen reader) combinations, before and after the patch. Some interesting differences, but none so far that would be a problem for signing off on this.
The reason I want to satisfy manual testing is that the skip-link is probably the single most important accommodation we have for sighted keyboard users (and by extension anyone whose assistive tech is set up to emulate a keyboard).
However, I still want to test iOS behaviour with a keyboard. I need to go to badger an iPhone user...
Comment #25
mgiffordComment #26
MaskyS commentedPatch applied cleanly and thus doesn't need reroll.
Comment #27
mgiffordHmm.. It failed when I tried it a week ago. Maybe it was a glitch on my end. Thanks!
Comment #29
apratt commentedI re-queued the patch for 8.4.x. It passed. I then manually applied the patch to an install of Drupal-8.4.x with PHP 7.1 and MySQL 5.7.17. The patch installed and appeared to do what it was supposed to do. I don't have the facility or knowledge to test against accessibility.
Comment #30
andrewmacpherson commentedI did some testing with this already, with a number of browers, with and with out a screenreader. I'll post the results in the next few comments.
Screenreaders still needing tests:
Comment #31
andrewmacpherson commentedThere was no appreciable difference before + after the patch withe the following set-ups:
Comment #32
andrewmacpherson commentedSince this patch only changes the CSS in the System module, testing should be done against with the Stark theme.
Not sure if that was obvious in the earlier comments.
Comment #33
andrewmacpherson commentedThe following set-ups had a minor difference, which is acceptable IMO. No screen reader was used here.
BEFORE the patch, the focus went to the empty
<a>and no outline appeared.AFTER the patch, focus outline appears on the entire
<main>element (faint grey on Chrome/linux and Opera/linux, clearer blue on Chromium/linux and Safari, Opera/mac, Chrome/mac, Chromium/mac)This is presumably the default Blink browser engine behaviour. We could try to override it, but I don't think it's worth the effort.
Comment #34
andrewmacpherson commentedI discovered a BIG difference with these set-ups, all the same beheviour.
BEFORE the patch:
<main>).AFTER the patch, a big difference:
<main>element - quite a difference!<main>). It's obviously mitigated by the fact that you can press the Control key to make VoiceOver stop talking.Given that Chrome, Chromium, and Opera all exhibit the same behaviour, and Safari doesn't, I'm going to assume this is down to a difference between what the Blink and WebKit engines send to VoiceOver via the Mac accessibility API. Drupal isn't giving an explicit label to the main landmark, so I'm going to put this down to bad behaviour on Blink's part, and say it's not a blocker for this issue. (We might want to mitigate this by giving our main landmark an explicit ARIA label, but that would be a separate (controversial) issue for later.
Since Safari + VoiceOver + macOS behaves nicely (the default applications for Macs), and none of these Blink browsers appear in combination with VoiceOver on the most recent WebAIM Screen Reader User Survey Results, then I reckon we don't treat this as a blocker for this issue.
Comment #35
andrewmacpherson commentedAndroid 6.x + Chrome + Talkback (latest versions, I think...) and a bluetooth keyboard.
No appreciable difference before and after the patch when using Talkback.
When using Android 6 + Chrome, without talkback, the same minor differnce as desktop browsers in #33. An outline is seen around the
<main>after using the skip link.I'm happy with this.
Comment #36
mgifford@andrewmacpherson sounds like you are ready to mark this RTBC, right?
Comment #37
andrewmacpherson commentediOS v10.2 + Safari tests and a bluetooth keyboard.
OK - no appreciable difference before/after the patch, with and without voiceover.
Comment #38
andrewmacpherson commented@mgifford - I'm happy with this so far. The only significant gaps in my manual testing have been with:
Do you have a JAWS set-up available?
I'm tempted to just say RTBC for this anyway.
<main id="main-content">as a skip-link target is a widespread enough in the wild...Comment #39
mgiffordI am happy to RTBC it at this point. As Andrew noted, this is a pretty common process at this time.
I don't have JAWS set up, but we don't test all accessibility patches with JAWS unfortunately. It would be better if we did.
If folks do want to test it again, I would remind folks that the theme needs to be set to Stark to see the changes.
We should create a follow-up issue for Stable and Classy maintainers that is either in the 8.4 or 9.x branch. @Cottser what is your view on where the follow-up issues to this should be?
Comment #40
xjmMaybe this can be a followup, but what about the following in Bartik and Seven templates?
As @Cottser said I think we probably can't change this in Stable or Classy in 8.x.
Comment #41
andrewmacpherson commentedEarlier on, I imagined the Bartik and Seven change would be follow-up, depending on whether it was eligible for Stable/Classy. However since we heard from @cottser in #21, we may as well do the Seven and Bartik changes here.
Comment #42
mgifford@xjm what do you think of @Cottser's concerns about it being too risky to change at this time?
Comment #43
xjm@mgifford, @Cottser said "I think it's too risky to change Stable or Classy templates for this." As far as I understand he is referring only to those, not to System module nor Bartik and Seven. Module and non-base theme templates can change in a minor release. This is covered by our BC policy: https://www.drupal.org/core/d8-bc-policy#themes
So as far as I know this patch is fine for 8.4.x, as would be one for Bartik and Seven.
Comment #44
cilefen commentedComment #45
mgiffordHere's some code with the other themes. I haven't tested it yet, but putting it up for the bots.
Comment #46
john cook commented@mgifford, Cottser's comment in #21 says not to change classy but the patch contains changes to a classy file. Is this intended?
Comment #47
mgiffordI misread what @xjm wrote & yes Classy shouldn't be included as "non-base theme templates can change in a minor release." So Bartik and Seven is fine but Stable & Classy aren't.
Easy fix though as the bots liked it.
Comment #48
mgiffordRe-roll without Classy.
Comment #49
andrewmacpherson commented#48 Looks good to me. Will RTBC once the test is green.
Comment #50
andrewmacpherson commentedRTBC for #48
Comment #52
xjmThe scope in #48 looks good to me.
@Cottser said:
That sounds like a frontend framework manager signoff to me, and we also have the requested accessibility signoff, including very thorough accessibility testing.
Now is a great time to commit this to 8.4.x, because that way there is plenty of time for it to be tested.
In these two, the
<section>is marked as themain-contentrather than the<main>. That seems correct to me, since it retains the hierarchy. I also checked that (as far as I can tell) there is no CSS that will be affected by these changes.Finally, I manually tested Bartik, Seven, and the Bartik maintenance page. In each case, the "Skip to main content" link properly took me to the main content, and nothing visually looked broken to my untrained eye.
Thanks so much for the careful review of this change! Committed to 8.4.x.
Comment #53
xjmOh, one more thing. I guess we should have a followup issue to update the Stable and Classy templates in 9.x, but I have no idea how we will handle deprecations for the frontend framework, and I imagine there will be many changes that we made internally that should go into the base themes for 9.x, not just this small fix.
For now, let's file a followup for 9.x for this issue and then we can split a broader discussion off of that if appropriate. Thanks!
Comment #54
chi commentedDoes anyone like the outline around main tag?
Comment #55
mgiffordoops.. sorry for re-testing that...
Comment #56
xjm@Chi, can you clarify what you mean or post a before/after screenshot illustrating it? Is this something I missed in my manual testing, and does the issue need to be reverted so we can discuss it?
Comment #57
xjmI think I see what @Chi might be referring to. When the
<main>receives focus, in some browsers, it becomes surrounded with a border (not a CSS border; one added by the client). When it was an empty<a>tag, no such border would have been visible. Is this what you meant?To me, that seems correct, and also more accessible for users of a graphical browser anyway. I ask to "skip to main content" and the browser's default behavior highlights for me where that content is, which helps me understand the information on the page. I don't think we should try to circumvent the client's behavior there.
If there is a different border that is caused by the template changes in this patch, one on the frontend rather than client-side, let's post a screenshot. If it also exists in HEAD, then a followup issue is probably better. Thanks!
Comment #58
chi commented@xjm, right, the question was whether that outline looks good for you.
It's not a big deal to disable it in a custom theme but for core and contributed themes you need to find a way to inject the CSS code.
One more thing I noticed, when clicking a checbox or radio button inside main area the outline is blinking.
Comment #59
mgifford@Chi I can replicate the focus in Seven. Basically any of the admin pages I tested, such as: /admin/config/people/accounts
I can see the outline in Chrome but not Firefox (just testing on a Mac).
I'm not sure this wouldn't be see as a feature rather than a bug. It's definitely different, but much easier to see where your focus is.
If we're going to address the inconsistency between browsers (possibly with main { outline: none; }) then I suggest we do this in a new issue.
Comment #60
andrewmacpherson commentedRe: #54 The outline around the
#main-contentelement was noticed in #33.It doesn't appear in all browsers; it seems to be just Webkit + Blink browsers. Firefox and IE don't show it. I have a suspicion it may be down to the fact we also have a
tabindex="-1", which was put in place to fix #1529814: Fix skiplink behavior for Webkit browsers.Normally, page-internal links to an ID #fragment would NOT produce a visible focus if the ID was on an element which isn't operable (e.g. the table-of-contents links on Wikipedia pages, which point to heading elements). Visible focus would normally only be indicated for interactive elements (links, buttons, etc.).
If we wanted to suppress it, we could try a CSS rule like
#main-content[tabindex="-1"] { outline: transparent; }. If so, we could do that as follow-up - I don't think it warrants reverting this commit.Comment #61
chi commentedFirefox does show it with different outline color, at least on my Linux installation (FF 42.0).
Comment #62
andrewmacpherson commentedThe style comes from Blink (and Webkit, presumably) browsers which have a user agent style like this:
This is present in Chrome 56, Chromium 55, Opera 43.0, and Vivaldi 1.7 (Linux versions). I don't have a copy of Safari available right now.
Comment #63
andrewmacpherson commentedI noticed something else: it doesn't affect Bartik.
It turns out that Bartik's
tabindex=-1andid="main-content"are on separate elements. See commit ed82b95. This goes some way to confirming my hunch that it is down to the tabindex fix for webkit browsers.Given that the #main-content element itself is not intended to be an operable element, and other page-internal fragment links (e.g. links to heading elements) do not gain a visible outline, I'm inclined to suppress the focus outline we are seeing here.
Comment #64
chi commented@andrewmacpherson, it does affect for me.
Comment #65
chi commentedWrong screenshot.
Comment #66
andrewmacpherson commentedRe: #65 - Thanks @Chi!
I recently closed #2852693: 508 Testing Issues - Skip to main content loses focus, works as designed. For consistency I think we ought to suppress the outline around
<main>which was introduced here.@xjm - since this is only in 8.4.x, and we aren't targeting it for 8..3.x backport, there's plenty of time to address the focus outline in a follow-up. Hopefully we don't need to revert this issue's commit?
Comment #67
xjm@andrewnacpherson Well, if we do consider the outlines a regression, we should revert it. The template markup changes are an improvement, whereas (based on your information) the borders are a small accessibility and visual regression (if they are miscommunicating that the element is interoperable when it's not).
Fortunately, same as we would have plenty of time to do followups, we also have plenty of time to add that fix to this patch if needed as well.
Edit: Less "commenting from an iPhone" run-on.
Comment #68
xjmAlright, I reverted this for the reasons above. If we agree that the focus border is not correct, then let's add the needed CSS along with the template changes. I think we'll probably also want a frontend framework manager's review before we recommit with that.
Thanks everyone!
Comment #73
andrewmacpherson commentedI forgot this was still open.
There's another approach we could take. Instead of removing
<a id="main-content" tabindex="-1"></span>tag and putting the ID directly on<main>, we could replace it with<span id="main-content" tabindex="-1"></span>.I expect this would solve the link-without-a-href semantic problem, without having to add CSS to avoid showing outlines on the
mainelement. I hope it would avoid some of the other problems I found too, but these would need a repeat of manual testing.Comment #76
damienmckennaNeeds a reroll.
Comment #77
damienmckennaUpdated per the suggestion in #73.
Comment #78
damienmckennaI noticed that VoiceOver on Safari behaves differently depending upon whether you type the "enter" key after bringing up the "skip to main content" button, or you use its recommended control-option-space combination. Simply pressing enter results in voiceover simply saying there's a link, with instructions on how to open the link, whereas if you use control-option-space it reads out the label of the link. Is this by design, or is there something else that can be done to improve the "enter" scenario?
Comment #79
damienmckennaA related article that cehfisher suggested: https://axesslab.com/skip-links
Comment #86
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #87
mgiffordAdding for Bypass Blocks SC.
Comment #89
rhithwik commentedWith #77 in the custom theme in my project, it solves issue from continuum scan error. The alternative approach tried was to add role="none", which also solves the same issue from continuum scan.
Comment #92
rpayanmI rerolled the patch from #77.
Please review.
Comment #93
smustgrave commentedWas tagged for a followup 7 years ago is that still needed?
Started the IS but it will need some updating too.
Comment #94
hitchshockReroled the last successful patch #77
Comment #95
goose2000 commentedI'm just mainly following, I need a theme that does ARIA landmark role="main" correctly; working on a university project. I was surprised to see this doesn't yet exist in D10.2 Olivero. I guess I can override this somehow until patches are in core.
Comment #96
mherchelDiscussed within Accessibility office hours February 15th (today) with several folks including A11y maintainers Mike Gifford and Ben Mullins.
This is a very low priority, and we're struggling to figure out the problem that this is solving. A potential problem, that's not in the IS, is that maybe the named anchor link will get styled unnecessarily, but I haven't seen this.
According to Ben Mullins, we need evidence that this is a problem, which we do not have. Closing and if anyone can post evidence that this is a real problem, please re-open.