From d07d4fce8c5bcc8eaf1ccaed580a34745749c8e2 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Sun, 16 Mar 2025 19:38:42 +0000 Subject: [PATCH] A11y: Add spoken notice when screen options are saved on change. When some screen option input fields are changed (post table columns, welcome panel, and metabox visibility), the change is saved to options. Other screen options (e.g. number of items per page) are only saved on submit. The changes that are saved immediately are visibly changed for sighted readers immediately. Change adds a `wp.a11y.speak()` call to inform screen readers that a value change has updated screen options. Props kkmuffme, joedolson, yogeshbhutkar, audrasjb, sourabhjain. Fixes #62550. git-svn-id: https://develop.svn.wordpress.org/trunk@59988 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/common.js | 18 ++++++++++++------ src/js/_enqueues/admin/postbox.js | 20 +++++++++++++------- src/js/_enqueues/wp/dashboard.js | 16 +++++++++++----- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 590796f4b2..0460e5a3f7 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -419,12 +419,18 @@ window.columns = { */ saveManageColumnsState : function() { var hidden = this.hidden(); - $.post(ajaxurl, { - action: 'hidden-columns', - hidden: hidden, - screenoptionnonce: $('#screenoptionnonce').val(), - page: pagenow - }); + $.post( + ajaxurl, + { + action: 'hidden-columns', + hidden: hidden, + screenoptionnonce: $('#screenoptionnonce').val(), + page: pagenow + }, + function() { + wp.a11y.speak( __( 'Screen Options updated.' ) ); + } + ); }, /** diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index c80866f3a2..b6d1b6569d 100644 --- a/src/js/_enqueues/admin/postbox.js +++ b/src/js/_enqueues/admin/postbox.js @@ -461,13 +461,19 @@ closed = $( '.postbox' ).filter( '.closed' ).map( function() { return this.id; } ).get().join( ',' ); hidden = $( '.postbox' ).filter( ':hidden' ).map( function() { return this.id; } ).get().join( ',' ); - $.post(ajaxurl, { - action: 'closed-postboxes', - closed: closed, - hidden: hidden, - closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), - page: page - }); + $.post( + ajaxurl, + { + action: 'closed-postboxes', + closed: closed, + hidden: hidden, + closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(), + page: page + }, + function() { + wp.a11y.speak( __( 'Screen Options updated.' ) ); + } + ); }, /** diff --git a/src/js/_enqueues/wp/dashboard.js b/src/js/_enqueues/wp/dashboard.js index 0115611fe9..5216611d5d 100644 --- a/src/js/_enqueues/wp/dashboard.js +++ b/src/js/_enqueues/wp/dashboard.js @@ -27,11 +27,17 @@ jQuery( function($) { * @return {void} */ updateWelcomePanel = function( visible ) { - $.post( ajaxurl, { - action: 'update-welcome-panel', - visible: visible, - welcomepanelnonce: $( '#welcomepanelnonce' ).val() - }); + $.post( + ajaxurl, + { + action: 'update-welcome-panel', + visible: visible, + welcomepanelnonce: $( '#welcomepanelnonce' ).val() + }, + function() { + wp.a11y.speak( wp.i18n.__( 'Screen Options updated.' ) ); + } + ); }; // Unhide the welcome panel if the Welcome Option checkbox is checked.