Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291123

Create a new AnnounceCommand to call Drupal.announce on an AjaxResponse

$
0
0

Problem/Motivation

In #2995689: Allow reordering blocks without a pointer device. we have the need to call Drupal.announce() to inform screen reader users that block list has been updated. Currently this patch has no javascript changes.
We currently have \Drupal\Core\Ajax\AlertCommand but no way to call Drupal.annouce() directly via an Ajax response.

Proposed resolution

Create \Drupal\Core\Ajax\AnnouceCommand that would call Drupal.announce()
This would make it easy to use Drupal.announce and encourage to its use when an ajax response should notify screen reader users of an update.

Remaining tasks

  1. Create command
  2. Create tests
  3. Manually test

To manually test:

  1. apply the patch
  2. enable the test module 'ajax_forms_test'.
  3. goto */ajax_forms_test_ajax_commands_form*
  4. click the button *AJAX 'Announce': Click to announce*
  5. Confirm the message appears in HTML <div id="drupal-live-announce" class="visually-hidden" aria-live="polite" aria-busy="false">This is my announcement.</div>'

User interface changes

none

API changes

none

Data model changes

None

Release notes snippet

The new Ajax command AnnounceCommand is now available to trigger screen reader announcements directly in Ajax responses. This command can be added to a \Drupal\Core\Ajax\AjaxResponse object like any other command that implements \Drupal\Core\Ajax\CommandInterface. The announcements will be made via the Drupal.announce() JavaScript method.


Viewing all articles
Browse latest Browse all 291123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>