Make WordPress Core

Opened 5 weeks ago

Last modified 4 weeks ago

#66283 new defect (bug)

Add skip link to navigate to admin notices panel

Reported by: joedolson Owned by:
Priority: normal Milestone: Future Release
Component: General Version:
Severity: normal Keywords:
Cc: Focuses: accessibility

Description

This is a follow-up to #50486.

That ticket proposed adding a conditional skip link that points to the admin notices container. It was not added in the initial commit, because I was uncertain it was actually desirable. There are two main reasons:

1) The existing Skip to Content link generally lands you only one tab away from the admin notice group.
2) I don't consider it desirable to introduce contextual variability to primary navigation methods.

Opening this issue for further discussion and work.

Change History (2)

#1 @sukhendu2002
5 weeks ago

Thanks for opening this, @joedolson. I looked at it against current trunk (after r64282). A few thoughts on your two concerns.

On (1), "one tab away": That's true when the notices come right after .wp-header-end. On many screens, though, there are several focusable elements between "Skip to main content" and the notices: the Screen Options and Help tabs, the "Add New" title actions, and sometimes plugin buttons placed next to the H1. On those screens it's 2–4+ stops, not one. And for screen reader users, the aside landmark from r64282 already lets them jump straight there with landmark navigation. So a skip link would mainly help sighted keyboard users who don't use landmark navigation.

On (2), contextual variability: I agree this is the stronger objection. The current skip links always appear in the same order with the same targets, and that predictability is useful. One option is to only *add* the link at the end, after "Skip to main content", and never reorder or replace existing links. The order users already know stays the same. Another option is to always show it and have it go somewhere sensible when there are no notices, but that seems worse to me than a link that sometimes isn't there.

If we go ahead: I think it should be added in JS, inside moveAdminNotices() in common.js, not in PHP. That's the only place that knows whether #wp-admin-notices actually exists:

  • WP_Admin_Notice_Collector counts .inline notices, which never go into the landmark. A page with only inline notices would get a skip link with no target.
  • It doesn't count notices that are echoed directly instead of going through wp_admin_notice(), even though JS still moves those into the landmark. Those pages would have notices but no link.
  • With JS disabled, the landmark is never created.

Roughly:

$( '<a href="#wp-admin-notices" class="screen-reader-shortcut"></a>' )
        .text( __( 'Skip to notices' ) )
        .insertAfter( '#adminmenumain .screen-reader-shortcut[href="#wpbody-content"]' );

Does this approach sound right? If so, I'm happy to open a PR.

#2 @joedolson
4 weeks ago

  • Milestone Awaiting Review → Future Release

Moving to future release along with #50486; it should probably be addressed along with #43484.

Note: See TracTickets for help on using tickets.