Make WordPress Core

Opened 7 weeks ago

Closed 6 days ago

#66189 closed defect (bug) (fixed)

Twenty Twenty Four: Missing nav aria-labels

Reported by: joedolson Owned by: joedolson
Priority: normal Milestone: 7.2
Component: Bundled Theme Version:
Severity: normal Keywords: has-patch commit
Cc: Focuses: accessibility

Description

Part of the process of moving bundled themes to meet new accessibility-ready standards.

Some of the template parts in Twenty Twenty Four declare nav menus without a default aria-label.

Attachments (4)

66189-before.png​ (56.3 KB ) - added by rahultank 6 weeks ago.
Page with the changed patterns, before patch
66189-after.png​ (56.9 KB ) - added by rahultank 6 weeks ago.
Page with the changed patterns, with patch (PR 13763)
66189-sidebar-before.png​ (56.8 KB ) - added by rahultank 6 weeks ago.
Useful Links sidebar navigation, before patch
66189-sidebar-after.png​ (53.1 KB ) - added by rahultank 6 weeks ago.
Useful Links sidebar navigation, with patch (PR 13763)

Download all attachments as: .zip

Change History (12)

This ticket was mentioned in ​PR #13763 on ​WordPress/wordpress-develop by ​@joedolson.


7 weeks ago
#2

  • Keywords has-patch added

Add omitted aria-labels.

Trac ticket: https://core.trac.wordpress.org/ticket/66189

Use of AI Tools

#1 @joedolson
7 weeks ago

  • Owner set to joedolson
  • Status new → accepted

@rahultank
6 weeks ago

Page with the changed patterns, before patch

@rahultank
6 weeks ago

Page with the changed patterns, with patch (PR 13763)

@rahultank
6 weeks ago

Useful Links sidebar navigation, before patch

@rahultank
6 weeks ago

Useful Links sidebar navigation, with patch (PR 13763)

#2 @rahultank
6 weeks ago

Patch Testing Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/13763

Environment

  • WordPress: 7.1.2 with Twenty Twenty-Four from WordPress.org (before) / trunk with PR #13763 and its bundled Twenty Twenty-Four (after), both in WordPress Playground
  • Browser: Google Chrome 153.0.8010.52
  • OS: Linux
  • Theme: Twenty Twenty-Four
  • MU Plugins: None
  • Plugins: None

Steps taken

  1. Activated Twenty Twenty-Four.
  2. Created a page containing the two changed patterns: twentytwentyfour/footer-centered-logo-nav and twentytwentyfour/hidden-sidebar.
  3. On the front end, checked the aria-label and the classes of every <nav> element (header, page content and footer).
  4. Repeated the same steps with the patch applied.
  5. ❌ Patch is only partly working.

Results

  • Footer with centered logo and navigation: ✅ the navigation now has aria-label="Footer" (before: aria-label=" 2"). Its layout is unchanged.
  • Header (parts/header.html): ❌ the navigation still has no aria-label. It also lost its layout classes: before it had is-horizontal items-justified-right is-content-justification-right, with the patch only wp-block-navigation is-layout-flex remains.
  • Hidden sidebar ("Useful Links"): ❌ the navigation still has no real label (aria-label=" 2", before " 3"). It also lost its attributes: the is-vertical class is gone, so the links are shown side by side instead of as a vertical list.
  • The footer part navigations (About, Privacy, Social Media) are unchanged, as expected.

Additional Notes

  • In parts/header.html and patterns/hidden-sidebar.php there is no comma between the new ariaLabel value and the next attribute (..."Primary', 'twentytwentyfour' ); ?>""layout" and ...'Sidebar', ... ?>""overlayMenu"), so the block attributes JSON is invalid and all attributes of those two navigation blocks are dropped.
  • parts/header.html is a static template part, so the <?php esc_attr_e() ?> call there is not executed; the file served from the PR build contains the PHP code as text.

Expected result

All three navigation blocks get a meaningful aria-label (Primary, Footer, Sidebar) and keep their existing layout and styles.

Screenshots/Screencast with results

Page with the changed patterns, before patch:
Page with the changed patterns, before patch

Page with the changed patterns, with patch:
Page with the changed patterns, with patch (PR 13763)

"Useful Links" sidebar navigation, before patch:
Useful Links sidebar navigation, before patch

"Useful Links" sidebar navigation, with patch:
Useful Links sidebar navigation, with patch (PR 13763)

​@joedolson commented on ​PR #13763:


5 weeks ago
#3

Thanks for suggesting the hidden template part; I'm not sure I would have thought of that.

#4 @nhrrob
5 weeks ago

Test Report

Description

This report validates whether the indicated patch works as expected. It re-tests the PR after the three commits from Oct 11, which addressed the problems in comment:2.

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/13763 (head 0cb1647)

Environment

  • WordPress: 7.2-alpha-63166-src (trunk e8a9e23)
  • PHP: 8.3.33
  • Server: wordpress-develop Docker environment
  • Browsers: Google Chrome (manual check with DevTools), Chromium (Playwright, automated check)
  • OS: macOS
  • Theme: Twenty Twenty-Four 1.6
  • Plugins: none

Steps taken

  1. Activated Twenty Twenty-Four.
  2. Created a page with the two changed patterns: twentytwentyfour/footer-centered-logo-nav and twentytwentyfour/hidden-sidebar.
  3. On the front end, inspected each <nav> element in the Chrome DevTools Elements panel. Recorded its aria-label, its classes and its list direction. A Playwright script checked the same values for every <nav> on the page.
  4. Applied the PR and repeated step 3.
  5. Opened the Header template part in the Site Editor and checked the Navigation block.

Actual Results

✅ The patch works as expected. Every navigation now has a real label, and no navigation changed its layout.

Navigation Before After Layout
Header (parts/header.html) no aria-label "Primary" unchanged (horizontal, justified right)
Footer with centered logo pattern " 2" "Footer" unchanged
Hidden sidebar pattern ("Useful Links") " 3" "Sidebar" unchanged (vertical list)
Footer part: About, Privacy, Social Media labelled labelled unchanged
  • No raw PHP is printed on the page.
  • The problems from comment:2 are fixed. The header navigation now has a label, and the header and sidebar navigations keep all their layout classes.
  • In the Site Editor, the Header template part loads with no invalid blocks. Its Navigation block has ariaLabel: "Primary" and the original layout.

Additional Notes

  • Tester tip: the new hidden-navigation.php file is not picked up until the theme pattern cache is cleared. Without that, the header shows no navigation at all. The cache is kept unless WP_DEVELOPMENT_MODE is theme or all, and I cleared it with wp eval 'wp_get_theme()->delete_pattern_cache();'. A real theme update changes the version and refreshes the cache, so users are not affected. The theme version should still be bumped when this is committed.
  • The latest review on the PR asks to remove the Categories and Block Types lines from hidden-navigation.php. That change is still open. It does not affect the results above.

Supplemental Artifacts

Before, ​header navigation has no aria-label
After, ​header navigation has aria-label="Primary"
After, ​centered logo footer pattern has aria-label="Footer"
After, ​hidden sidebar has aria-label="Sidebar" and keeps is-vertical

​@joedolson commented on ​PR #13763:


6 days ago
#5

These changes are materially consistent with other themes and do not materially change the previously tested changes. My testing demonstrates that they work as expected without changing existing behaviors, so approving.

#6 @joedolson
6 days ago

  • Keywords commit added

#7 @joedolson
6 days ago

  • Resolution → fixed
  • Status accepted → closed

In 65351:

Twenty Twenty Four: A11y: Add aria-label in default menu names.

Add missing default aria-label values to the hidden-sidebar, header, and footer with centered logo patterns in Twenty Twenty Four.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/13763.

Props joedolson, mukesh27, rahultank, nhrrob, harishtewari.
Fixes #66189.

Note: See TracTickets for help on using tickets.