Skip to content
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

Button Block: Add HTML Element selection in Advanced settings (accessibility) #63534

Open
amberhinds opened this issue Jul 14, 2024 · 13 comments
Labels
[Block] Buttons Affects the Buttons Block [Type] Enhancement A suggestion for improvement.

Comments

@amberhinds
Copy link

What problem does this address?

Currently, the Button block only outputs links. Users frequently misinterpret its name. They use the "button" block to trigger modals and other elements that should be triggered by a true HTML button, not a link. This adds accessibility problems to websites, particularly for screen reader users.

Additionally, there are instances where users add groups of links with the button block that should be contained in an HTML list or that function like navigation and should be contained in an HTML nav tag.

These three things are issues that I frequently encounter while accessibility auditing websites built with the block editor. The current solution is to replace core blocks with custom blocks or to write Javascript to remediate the issues. We need to make it easier for users to avoid or fix accessibility issues in a no-code way.

What is your proposed solution?

This block would be greatly enhanced with the addition of several dropdowns in the advanced section that allow developers and more advanced content creators to adjust the markup of the link itself and surrounding markup.

Something similar to the HTML element dropdown on the Group block
Screenshot expanded HTML element selector

This is what we would need:

  1. HTML element selector for button:
  • <a> default
  • <button>
  1. Group HTML element selector:
  • <div> default
  • <ul>
  1. Parent container HTML element selector
  • <div> default
  • <nav>

If a nav tag is set for the parent container, we need to give users the ability to add an aria-label so there would need to be a text field that conditionally appears.

@amberhinds amberhinds added the [Type] Enhancement A suggestion for improvement. label Jul 14, 2024
@Mamaduka Mamaduka added the [Block] Buttons Affects the Buttons Block label Jul 14, 2024
@Mamaduka
Copy link
Member

Note: The Buttons block already supports using the button element; I thought there was no UI. See #54206.

@carolinan
Copy link
Contributor

Yes this feels more like an education and documentation issue.

  • Explain better how to change the element
  • More examples of using the interactivity API correctly to create these UI's.

@ndiego
Copy link
Member

ndiego commented Jul 15, 2024

Note: The Buttons block already supports using the button element;
Yes this feels more like an education and documentation issue.

Yes, I didn't even know this was possible. 😅

Is there an explicit reason why there is no UI for this?

@carolinan
Copy link
Contributor

Yes, to prevent users from setting it to the button element by mistake or doing it wrong.

@carolinan
Copy link
Contributor

This is also why we need the block reference to list all the available block supports and block attributes in a searchable way.
For example "show all blocks with the tagname" which would have shown that one can change the tag for the block.
(Instead of relying on third-party sites to do that.)

@amberhinds
Copy link
Author

Yes, to prevent users from setting it to the button element by mistake or doing it wrong.

I have a hard time with this response. If we want to make it easier for people to build accessible websites without having to write code, there should be a UI for it and in-editor documentation that explains the difference between a button and a link to educate users on what to choose.

If it's only available via the interactivity API, the vast majority of people will not know how to do it. They'll continue using the button block to create click-triggered modals (which a non-dev can do with a plugin like Popup Maker).

@carolinan
Copy link
Contributor

Without user testing, there is no way to know which would be the higher risk.
The risk that a user changes the element thinking it will behave like a button without any other changes is not a minor issue either.

@amberhinds
Copy link
Author

If they set it to a button and then didn't connect it to something else (either with a plugin or custom code), it would not do anything, right? Theoretically, they would notice that clicking it does nothing when testing their website.

Based on my auditing, a misused link is more likely than a misused button. And the misused link happens all the time.

@amberhinds
Copy link
Author

I'd also be happy to remove the word button from the block title and name it to something else, but I figure that's already been discussed and is a nonstarter.

@carolinan
Copy link
Contributor

I am not sure how to move forward with this.

  • The code change in the block is relatively small, unless it ends up needing a deprecation.
  • A help text that explains when to use the option is difficult to get right.
  • I worry that if we add it we might not be able to remove it again and need to support it forever even if we see users misusing it or confused by it.

@amberhinds
Copy link
Author

amberhinds commented Aug 17, 2024

I worry that if we add it we might not be able to remove it again and need to support it forever even if we see users misusing it or confused by it.

The challenge here is that people are already misusing the current "button" block because they don't understand that it cannot be used to create an HTML button and there is a way to "fake" a button by linking to just a hash.

Adding the ability to set a <button> tag is far less likely to be misused than the current block is already being misused. It is less likely to be misused because a link that has been changed to a button tag by a user who doesn't understand HTML would literally not function. The user will try to click on it with their mouse, and it will do nothing. They will then switch it back to a link, and it will work.

The problem with the current block is that the misuse <a href="#"> appears to work when nonsavvy users click it with their mouse, so they think nothing is wrong with it. Even worse is people who don't put anything in the href and write JS to target it. They still think it works if they're not keyboard testing (which they probably are not).

How about this for helper text?
"A link (<a>) takes users to a new page or section of a page. A <button> performs an action on the page, such as opening a modal or expanding a collapsed section. More about buttons vs links. (link)"

Here are possible articles that could be linked to for the more link:

@joedolson
Copy link
Contributor

I'm inclined to agree with @amberhinds - this block is already heavily misused. I have personally encountered button blocks with no href attribute in numerous audits, and so there is no question that the block is actively misused as it is.

If we do not want to make it possible to use a button element, then I think we should toggle this to a non-semantic element if it does not have a link added.

However, I don't think that being able to convert this into a button element creates a worse situation than we already have. Right now, we have "links" that don't operate as links; after, we could also have buttons that don't operate as buttons.

I do think that if we add the button option without the ability to create interactivity within the interface we are creating a confusing situation for the user, since they can't create a button that has functionality. However, having a code-based way to enable this would make this more extendable by those who need it.

Overall, my concerns are more about the fact that this can create an a element without href and that there's no option to have an organizational structure for groups of buttons.

@symbiotisk
Copy link

I'll chime in here and say as someone who both develops sites and helpw our clients maintain them 99% of our clients do not know that groups have an option to be header, aside etc. etc.

It's fine that it's doable through code, but essentially hard for us to deploy especially on sites where the content has been created over several years of use on a site where we could make their buttons accessible, just by switching the mark-up on given blocks, but also teaching users how it's done, so they can do it retroactively.

Having this option would help us as developers immensely and not affect most of the user base in any way or form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

6 participants