#55537 closed enhancement (fixed)
Pair wpAjax admin notices with accessible audible messages
Reported by: | afercia | Owned by: | joedolson |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch commit |
Focuses: | accessibility, javascript | Cc: |
Description (last modified by )
Splitting this out from #47018.
Amongst other things, the window.wpAjax
response takes care of displaying success / error admin notices on some pages. In [52170] a couple of these notices were paired with accessible audible messages via wp.a11y.speak
.
There are a few more notices that can benefit from the same audible messages, which are typically the responses triggered when wp_die()
is used.
Attachments (2)
Change History (14)
This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.
2 years ago
#3
@
2 years ago
- Milestone changed from Awaiting Review to 6.1
We reviewed this ticket today during the Accessibility Team's bug-scrub.
As the ticket seems to be already in good shape, we decided to milestone it for 6.1.
#4
@
2 years ago
- Keywords needs-refresh added; needs-testing removed
The patch no longer applies. I will try to fix it if no one gets to it first.
#5
@
2 years ago
- Description modified (diff)
- Keywords needs-testing added; needs-refresh removed
Thanks @alexstine.
I went ahead and refreshed the patch against latest trunk. See 55537.2.diff
#6
@
2 years ago
@afercia The patch is working great for me. All cases seem fine. Think this could be marked early for 6.1?
#7
@
2 years ago
@alexstine thanks for testing. I'd defer the decision to the a11y team (I don't have much time to attend the meetings, sorry).
This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.
2 years ago
#10
@
2 years ago
- Keywords commit added; needs-testing removed
Tested with VoiceOver/Safari and JAWS/Chrome, JAWS/Firefox. Works as expected; marking for commit.
55537.diff adds accessible audible messages to three more cases in
ajax-response.js
where admin notices are displayed, so that the visual notices are paired with audible messages.Following the code in
wpAjax.parseAjaxResponse
, see https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/ajax-response.js?rev=52672&marks=20-67#L18It first checks whether it's a
WP_Ajax_Response
xml response, handles the response and returns it. After that, there are 3 more cases:isNaN(x)
: the response is not a number. Rather, it's a string. Typically, a custom message passed towp_die()
e.g.wp_die( __( 'Some error message' ) )
.-1 === x
: this is whenwp_die( -1 )
is used and it's associated with the default message 'Sorry, you are not allowed to do that.'.0 === x
: this is whenwp_die( 0 )
is used and it's associated with the default message 'Something went wrong.'.Worth noting that in all these three cases, the existing code already displays some text in an admin notice.
This patch just uses the same text displayed in the admin notice to trigger an audible message for screen reader users via
wp.a11y.speak()
.Additionally:
error
andupdated
are legacy classes and should not be used any longer. Since a few years, the admin notices use a new pattern e.g.notice notice-error
,notice notice-success
, etc.To test:
I can't think of an easy way to test this other than altering the code. For example:
wp_ajax_add_tag()
function, before the creation of theWP_Ajax_Response
instance, add the following code:wp_die( -1 );
a11y-speak-polite
.wp_die( -1 );
towp_die( 0 );
and repeat the test. The message text will be 'Something went wrong.'.wp_die( 0 );
towp_die( __( 'My custom message' ) );
and repeat the test. Of course, the message text will be 'My custom message'.