Repository navigation
Posts, Post Types: Add a presentation role to taxonomy tab list items - #16086
abhishekfdd wants to merge 2 commits into
Conversation
The taxonomy and link category meta boxes render their tabs as `ul[role="tablist"] > li > a[role="tab"]`. The `li` elements keep their implicit `listitem` role, so the tablist's owned children are list items instead of tabs, and each list item has no `list` parent. Automated checkers report this as `aria-required-children`, `aria-required-parent` and `listitem` violations. Add `role="presentation"` to the `li` elements in `post_categories_meta_box()` and `link_categories_meta_box()`, so the tabs become the tablist's direct children in the accessibility tree. This is the approach described in the ARIA Authoring Practices Guide's "Hiding Semantics with the presentation Role", and matches the embed share dialog tabs. Follow-up to [61764]. See #66725.
…tab sequence. The "Most Used" tab in the taxonomy and link category meta boxes is rendered without `tabindex="-1"`, so both tabs are in the Tab sequence until the user activates a tab and the script sets `tabindex` on them. The tabs pattern expects only the active tab to be reachable with Tab, with the arrow keys moving between tabs. Render the inactive tab with `tabindex="-1"`. When the user setting restores the "Most Used" tab on load, the script's triggered click already removes `tabindex` from that tab and sets `tabindex="-1"` on "All", so no script change is needed. Follow-up to [61764]. See #66725.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Since [61764],
post_categories_meta_box()andlink_categories_meta_box()render their tabs asul[role="tablist"] > li > a[role="tab"]. Thelielements keep their implicitlistitemrole, but atablistmust owntabelements, and alistitemneeds alistparent. axe-core reportsaria-required-children,aria-required-parentandlistitem.Commit 1: Add
role="presentation"to the tab list itemsThis fixes the markup reported in the ticket. It adds
role="presentation"to bothlielements in each function, so the tab list owns its tabs directly. The ARIA Authoring Practices Guide describes this approach in Hiding Semantics with the presentation Role. Core already uses the same markup for the embed share dialog tabs insrc/wp-includes/embed.php.Impact: In the browsers I could check, this is a validity fix. It removes the reliance on browsers repairing the markup, rather than changing what those browsers currently expose:
lielements as presentational on trunk. Neither exposeslistitemnodes between the tab list and the tabs, before or after the patch.listitemlevel appears in spec-based role calculation, as used by axe and Playwright'sariaSnapshot(). That showstablist > listitem > tabon trunk andtablist > tabwith the patch.Classes, whitespace and attribute order are unchanged. No JS or CSS depends on the
lirole:post.jsandlink.jsselect with#<tax>-tabs a/#category-tabs a,.parent(),.parent('li').next()/.prev()and.siblings('li'). All of these use the DOM tree, not the accessibility tree.edit.cssstylesul.category-tabs liby element and class. Nothing insrc/wp-admin/cssuses a[role]selector on these elements.Commit 2: Remove the extra Tab stop on the inactive "Most Used" tab
I found this keyboard bug while testing the fix. On trunk, after a fresh page load, the Tab after "All" stops on "Most Used" before leaving the tab list, because "Most Used" is rendered without
tabindex="-1". In the tabs pattern, only the active tab is in the Tab sequence, and the arrow keys move between tabs. The extra stop disappears only once the user activates a tab and the script setstabindex.This commit renders the "Most Used" tab with
tabindex="-1"in both functions. No JS change is needed:tabindex="-1"on every tab and removes it from the clicked one..hide-if-no-js.It is a separate commit so it can be reviewed, or split out, on its own. If a committer prefers, I'm happy to move it to a new ticket.
Testing instructions
Setup:
$tax_namepath: register a second hierarchical taxonomy for posts. For example, add this to a mu-plugin:add_filter( 'pre_option_link_manager_enabled', '__return_true' );, then open Links > Add New.Accessibility checks (commit 1):
aria-required-childrenon eachul.category-tabs,aria-required-parenton each tab link andlistitemon eachli. After: none of these in the tab lists.lielements haverole="presentation".Keyboard checks (commit 2), for each tab list:
aria-selected/tabindexmove to the new tab.tabindex="-1".Results
I tested with Chrome 157 and axe-core 4.10.2. The ticket was filed with axe-core 4.14.1, and the same three rules exist in both.
Full results are in the Trac ticket.
Trac ticket: https://core.trac.wordpress.org/ticket/66725
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Investigating the markup and JS, preparing both commits, running the axe, keyboard and accessibility tree checks in a local environment, and drafting this description. I reviewed the code, test results and text, and take responsibility for them.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.