Accessibility: Make Customizer back button keyboard focusable
Trac ticket: https://core.trac.wordpress.org/ticket/63011
This PR fixes the accessibility issue where the Customizer back button was not keyboard-focusable. By removing the tabindex="-1" attribute from the back button in the Customizer section template, keyboard users can now navigate to and activate the back button.
Before -
https://github.com/user-attachments/assets/0c4c595b-a921-4b96-ae51-54eb764dbd02
After -
https://github.com/user-attachments/assets/281353ff-6fe4-42ab-b41a-095d8ae25e9a
Test using WordPress Playground
The changes in this pull request can previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.
Some things to be aware of
- The Plugin and Theme Directories cannot be accessed within Playground.
- All changes will be lost when closing a tab with a Playground instance.
- All changes will be lost when refreshing the page.
- A fresh instance is created each time the link below is clicked.
- Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.
Core Committers: Use this line as a base for the props when committing in SVN:
Props abcd95, ankitmaru, wildworks.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.
Here is a screencast of the keyboard navigation for all the sections -
https://github.com/user-attachments/assets/2e8609ae-8ef5-413a-a49c-bfd40ed676bc
@himanshupathak95 Thanks for the patch! The fix works well, and making the back button keyboard-focusable improves accessibility. 👍
Thanks for the PR!
I think there are a few additional things that need to be addressed to fully address this issue.
- The default value of the
typeattribute on thebuttonelement issubmit. We may want to usetype="button"to avoid unintended behavior. - There seem to be other non-focusable back buttons. We may want to investigate where they are used and whether they should be fixed as well:
- There is JS code that removes the tab index. We may want to investigate whether this can be removed as well (Source).
- We may also need to modify QUnit tests (Example):
Thanks, @t-hamano, for the suggestions.
I have updated all the places needed for keyboard navigation. After testing, I found that the JS code change is not necessary since the tabindex attributes are being added directly in the PHP templates. Also, the Qunit tests are not affected either, but I am not sure if we have to update them.
A commit was made that fixes the Trac ticket referenced in the description of this pull request.
SVN changeset: 60482 GitHub commit: https://github.com/WordPress/wordpress-develop/commit/74c101b3dffff9fee96eb4da92cd55884d908cda
This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.