Postponed
Project:
Drupal core
Version:
main
Component:
block.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Sep 2016 at 12:16 UTC
Updated:
29 May 2023 at 19:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mgifford+1 - ARIA is powerful, but not as good as old HTML5.
Some links to back that up:
https://www.paciellogroup.com/blog/2011/04/html5-accessibility-chops-jus...
http://www.karlgroves.com/2013/05/14/links-are-not-buttons-neither-are-d...
Comment #3
andrewmacpherson commentedHmm, life's never easy.
The place-block buttons come from
core/modules/block/src/BlockListBuilder.php, and are treated as Form API link elements. The#urlproperty is used to build an ajax dialog request for theblock.admin_libraryroute, so changing to a HTML button isn't a simple change.Interestingly, when Javascript is disabled in the browser, "place block" does indeed act as a link, directing the user to the block library as a standalone page.
It's the same story for the buttons inside the dialog. When JS is disabled, they are links which direct to the block configuration form as a standalone page. So with JS disabled, the user visits 2 separate pages instead of getting each step inside a dialog.
When JS is enabled, and the dialogs come into play, "button" is a more appropriate semantic.
The ARIA
role=buttonapproach may be the better option. We could have a JS behaviour which adds the role and a keypress handler for the spacebar.Comment #4
Everett Zufelt commentedI assume that it would be relatively simple to add the role=button attribute? I assume that if this is already an anchor that it would be suitable in all other ways from an accessibility perspective, but some quick testing could confirm.
- Can receive focus
- Visually displays focus
- In an appropriate tab order / flow.
- Can be activated by keyboard.
Comment #5
prashant.cSubmitting patch for the same adding
role="button"attribute to place block links.- It is receiving focus on appropriate tab order / flow.
- Visually displaying focus
- Working on enter key.
Comment #6
BarisW commentedComment #7
gaëlgI'll try to review this as part of DC Dublin friday sprint.
Comment #8
gaëlgThe initial post says that space key activation is required. I'll try to work on it now.
Comment #9
gaëlgI added a JS behavior to handle the spacebar. Patch attached.
I sat next to Andrew during the sprint and we discussed about a wider issue: it might be good for accessibility if every link with role=button would respond to the spacebar key press, not just the "Place block" one. I found at least one other "pseudo-button" in core: the "Manage" link in the admin toolbar menu. Might be another issue though.
Edit: wider issue created: #2809347: All links using the "button" role should respond to spacebar, not only to enter key
Comment #10
gaëlgComment #11
andrewmacpherson commentedThanks GaëlG.
I think we can improve this comment. I suggest:
"Allow user to activate Place Block link with spacebar key. This is the expected behavior of an element with the button role."
Comment #12
gaëlgHere's a new patch, I just updated the comment as asked.
Comment #13
andrewmacpherson commentedI tested this with @GaëlG and the behaviour worked in Chrome, but not in Firefox.
There is a problem with keyCode in jQuery on Gecko, according to https://stackoverflow.com/questions/12172646/event-keycode-vs-event-which
Using event.which == 32 worked as expected on Firefox.
Comment #14
gaëlgHere's an updated patch. I confirm it still works on my Chromium.
Comment #15
kostask commentedandrewmacpherson I can't get safari, nor firefox (on a mac) to focus the link using the tab button. How did you manage to get firefox to focus it?
Comment #16
kostask commentedresetting the tags I removed by mistake
Comment #17
mgiffordSorry, but why have we given up on
<button>and reverted torole="button"?HTML5 is better supported.
Comment #18
tim.plunkettAFAIK button elements do not support href.
Comment #19
droplet commentedNot a fans to add similar JS code everywhere. Let's make it globally
Comment #20
mgifford@tim.plunkett - I just re-read the issue description and have modified the title. The problem is with the identification to screen readers which can be fixed with aria.
There are many instances where aria is used rather than plain old HTML, when HTML would be more accessible for everyone. This doesn't seem to be one of those instances.
@droplet - How do we do this? Where are these links (which act as buttons) being built? Not sure how to change it globally.
Comment #21
tim.plunkettThese specific links are in BlockListBuilder, around line 211.
The two key parts there are
'#type' => 'link'andComment #24
andrewmacpherson commentedRe: #15
This is likely down to the system-wide macOS setting of "full keyboard access" which controls whether TAB can move focus to a link. I believe the default behaviour is that TAB does not move focus to links. See Mac accessibility shortcuts - Firefox and Safari both respect this setting. I was most likely testing with Firefox on Linux.
Re: #17
Because when JS is turned off, these do indeed act as links, and they use a href to load a new page, instead of a dialog.
If we want them to work with JS turned off, then
<button>won't work. A href is needed.The patch in #14 adds the button role via PHP, which has no way of knowing whether JS is turned on.
But with JS turned off, an
<a role="button" href>won't have the expected spacebar behaviour.Removing the novice tag, as we don't have a clear direction on this one yet.
Comment #25
andrewmacpherson commentedThis issue overlaps with #2809347: All links using the "button" role should respond to spacebar, not only to enter key - we could postpone this, and explore a solution there. It applies to other parts of the admin UI too, e.g. Views.
Comment #37
mgiffordTagging https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html