-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editable blocks have inconsistent ARIA role: sometimes textbox, sometimes document #42158
Comments
From a technical side: I'm not sure why As noted earlier, seems to me
What is the actual purpose of the |
I forgot to ping some members of the accessibility team 🙂 @alexstine @joedolson for some insights on previous testing and discussion. Thanks! |
This is a tricky one because I believe role document allows us to place focus on the block wrapper and have screen readers announce it. I tried removing the role once and it produced terrifying results. In the table block for example, it read the figure tag instead of the aria-label that adds context. There is a lot wrong with how we currently do things in Gutenberg and I hope it gets better with time, but I just do not have the bandwidth to take on much at the moment. If you want to open a quick test PR and change the default role in useBlockProps hook, we can see what happens. |
Thanks @alexstine |
Doubt it but cannot say for sure. I can test this weekend if you need but I never really made it as far as testing specific blocks. My main focus so far has been trying to improve the blockers around the editor as a whole. E.g. functionality that effects all blocks and how you interact with the content. If you think about it though, I am not sure screen readers would be better off announcing blockquote. This seems like it could make the situation worse. It will output a blockquote, but in theory, it is not a blockquote yet. That is how I think about it though. Thanks. |
@alexstine agree. I think we're mixing up a bit different topics. Sorry if I wasn't clear. The block wrapper and the block editable area are (or better: should be) two different things. The The block wrapper is a different thing. I explored a bit previous versions of the editor and I see the block DOM structure has changed a lot over time. I think many of these changes originate from the work done to 'lighten' the blocks but the situation now is pretty confused and the HTML of many blocks is inconsistent. Sometimes block do have a wrapper element. Sometimes don't. To my understanding, in previous versions of the editor, all blocks used to have a wrapper element. This has a impact when it comes to the way ARIA roles and attributes are applied to the blocks markup. A quick example based on the Heading block: In WordPress 6.0, the Heading block doesn't have a wrapper element:
I don't mind that much about the H2 semantics being overridden. What's wrong here is:
In WordPress 5.3, for example, there was a a wrapper element:
Overall, the current blocks markup is largely inconsistent and I think it does have an impact on assistive technology. To my understanding there are two main issues here:
This inconsistency is less than ideal from an accessibility perspective. |
@afercia Oh yes, I understand now. I am not sure why not all blocks have wrappers or why some blocks try to have wrappers/content in one. It makes little sense as an insider looking in, you are correct. @talldan @tellthemachines Do you have any idea why this was changed? Cleaning up HTML would be my best guess? @afercia Have you tried overriding the prop for a single block or even in RichText? Something like this?
I am fairly positive you can override that property and if not, you can change it for testing at block-editor/src/components/block-list/use-block-props/index.js I believe. I have done a fair amount of work here and other related called hooks. Would be interesting to see what happens with correct role usage. In theory, screen readers should still switch in to edit mode so I would be happy with that. |
Pretty much. There has been an effort to make the block HTML in the (backend) editor match the block HTML on the frontend of a site. On the frontend, a paragraph block will only output a paragraph element, so the editor now does the same. It makes it possible for a block in the editor to more closely match the frontend styling. I can't recall exactly how it worked before in the editor, possibly there were lots of I think this is the PR that changed things - #23034. |
@alexstine thanks for the hint. Not sure overriding the prop would be the best option as it would require to fix the role on a case by case basis, only when @talldan thanks for looking into this.
Yep, some block still use div elements or other elements as wrappers. I'm not sure that's the root cause though. It's just that Update:
It should be:
The first label is the one that used to be set on the block wrapper. It now overrides the label of the editable RichText. This has an impact on the way the various block are exposed to assistive technology. Actually, the labelling is pretty inconsistent. |
Currently, the
I'm wondering if there's a need for this to be so; from an accessibility perspective, is there a valid reason for |
Furthermore, |
To recap the current situation and further clarify my comment on #47276:
Basically, the presence of the wrapper element and the usage of |
A good way to test the inconsistencies across blocks would be comparing the way various screen readers behave on the Paragraph block and on the Quote (or Pullquote) block. To me, a contenteditable element should always have a `role="textbox'. Feedback from assistive technology makers would be very very welcome ❤️ 🙏 to make sure that wouldn't introduce weird behaviors for old versions. See the discussion on #29526 |
I wanted to revive this discussion as I am currently playing around in a PR where I am looking at removing As far as blocks with wrappers and without wrappers, apparently this was done to match the front-end visually and will likely not change so we've got to make the best of it. |
@alexstine, do we know where this issue stands today? I tried overwriting the role="document" attribute where it was suggested:
But apparently, that feature hasn't been implemented yet? Setting blocks to default to role="document" might be ok as long was we can overwrite the value in useBlockProps(). |
@salvatoremark No movement at this point. BTW, why are you adding the presentation role? That will remove all semantics for assistive tech. I can understand the ability to override the role but not with presentation. |
This particular block is decretive.
From what I understand, the “presentation” role is the same as “none”. The assistive tech would simply ignore it.
Thanks Alex!
… On Apr 5, 2024, at 5:44 PM, Alex Stine ***@***.***> wrote:
@salvatoremark <https://github.com/salvatoremark> No movement at this point. BTW, why are you adding the presentation role? That will remove all semantics for assistive tech. I can understand the ability to override the role but not with presentation.
—
Reply to this email directly, view it on GitHub <#42158 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ARSVYTK6ERTY5EWS6XBISMDY34LKLAVCNFSM52WJNHG2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBUGA3DMOBWGQYA>.
You are receiving this because you were mentioned.
|
Can you provide more detail on how this is decorative, @salvatoremark ? I'd argue that it's not possible for any block to be decorative in the admin; if an editor is working with the document, they always need to be able to identify the block in a meaningful way. It's similar to how images in the media library cannot be decorative, because the purpose of the media library is to display the images in the library. |
Yes, I can see that it’s not possible for a block to be decorative in the admin. I was assuming that the role would carry over into the frontend, where it should likely be possible to designate a block as “presentation”. I think Alex suggested it could be passed with useBlockProps.save( { role: “presentation” } ) in save.js.
Just so you know, the blocks I’m building are for my purpose of learning. This question arose while building a block that applies a choice of eye-catching effects to a string of text. It carries no meaning aside from being eye candy, so it could likely fall into the category of presentation.
So back to my original question and the current state of things, the ARIA role=“document” is auto-inserted for blocks in the admin. And as of yet, there’s no way to designate that role, or any ARIA role for a block on the frontend?
… On Apr 5, 2024, at 6:11 PM, Joe Dolson ***@***.***> wrote:
Can you provide more detail on how this is decorative, @salvatoremark <https://github.com/salvatoremark> ? I'd argue that it's not possible for any block to be decorative in the admin; if an editor is working with the document, they always need to be able to identify the block in a meaningful way. It's similar to how images in the media library cannot be decorative, because the purpose of the media library is to display the images in the library.
—
Reply to this email directly, view it on GitHub <#42158 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ARSVYTPJIZRLHGX4PEPP7W3Y34OQLAVCNFSM52WJNHG2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBUGA3DSNJQGMYQ>.
You are receiving this because you were mentioned.
|
Not that I know of. You might be able to do it with index.php file but I do not think you can in save.js. Would need someone else to confirm. |
Description
Blocks that have an editable area use the
RichText
component that renders an HTML element with acontenteditable
HTML attribute. This provide users with an area where they can enter text.Semantically, these editable areas need to be exposed to assistive technology as editable 'fields'.
In terms of ARIA roles and attributes:
role="textbox"
is the equivalent of a HTML text input field.role="textbox" aria-multiline="true"
is the equivalent of a HTML textarea and should be used for most of these editable areas.The
RichText
component defaults torole="textbox"
and that's correct.However, with the introduction of
useBlockWrapperProps
in #23034 (later renamed touseBlockProps
) things have changed and now editable areas have inconsistent ARIA roles.Note that, initially,
useBlockWrapperProps
used to pass an ARIArole="group"
even though I think the group role was added even before in #19701. That was incorrect and was fixed in #33627 by changing thegroup
role todocument
. However, seems to me that fixed the symptom rather than the root cause. Editable areas should always have atextbox
semantics.Seems to me the root cause is that
useBlockProps
is used inconsistently. Sometimes, it's used on theRichText
wrapper. Sometimes, it's used directly on theRichText
component itself. In this last case, therole="document"
provided byuseBlockProps
overrides theRichText
roletextbox
.I read along the discussion on #29526 and #33627 and I see the fix provided there was discussed and tested by the accessibility team. I'd like to hear from the team and have some discussion but I'd tend to think all the editable areas should have a consistent ARIA role of
textbox
.Step-by-step reproduction instructions
contenteditable
attribute:Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: