bug js file:
core/misc/announce.es6.js
core/misc/announce.js

This file has the following bug code:

  Drupal.announce = function(text, priority) {
    // Save the text and priority into a closure variable. Multiple simultaneous
    // announcements will be concatenated and read in sequence.
    announcements.push({
      text,
      priority,
    });
    // Immediately invoke the function that debounce returns. 200 ms is right at
    // the cusp where humans notice a pause, so we will wait
    // at most this much time before the set of queued announcements is read.
    return debounce(announce, 200)();
  };

here "return debounce(announce, 200)();" , It's a misunderstanding of debounce ,
fixed to:

  let announce_debounce = debounce(announce, 200);
  Drupal.announce = function (text, priority) {
    announcements.push({
      text,
      priority,
    });
    return announce_debounce();
  };

Sign-offs needed

Regressions here would be serious. Manual testing with screen readers is important. Get sign-off from an accessibility maintainer.

Comments

yunke created an issue. See original summary.

shreyal999’s picture

Assigned: Unassigned » shreyal999

Working on its patch. Will update it soon.

shreyal999’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

Updated the JS script as per the description. Kindly review the patch and suggest changes if any.

andrewmacpherson’s picture

Version: 8.7.3 » 8.8.x-dev
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -announce +Accessibility, +Needs accessibility review

Regressions here would be serious. Before committing any change to the inner workings of Drupal.announce(), there should be manual testing with a range of browser/screenreader combinations.

Review of patch #3:

There's an ES6 let in announce.js - but that's supposed to be ES5, after compiling the ES6 file. Did you follow the process for working on core Javascript files? For instructions, see these links:

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

nod_’s picture

Assigned: shreyal999 » Unassigned
Issue tags: +Novice
anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new1.33 KB

Not able to generate the interdiff.

anmolgoyal74’s picture

StatusFileSize
new1.33 KB
new1.26 KB
nod_’s picture

Status: Needs review » Needs work

Thanks for the patch!

+++ b/core/misc/announce.es6.js
@@ -102,6 +102,7 @@
+  const announceDebounce = debounce(announce, 200);

This is getting in the way of the method documentation. It's better to place this before the comment of the Drupal.announce method.

nod_’s picture

Title: JS bug:Drupal.announce » Drupal.announce debounce usage issue
vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB
new624 bytes

Updated patch according to the #11.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Appears to still need accessibility review.

_utsavsharma’s picture

StatusFileSize
new847 bytes
new847 bytes

Patch for 10.1.x.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

May be my limited javascript knowledge but how does one go about triggering this issue.

Since this was filed as a bug think it would be useful to have a test case that shows this issue.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture

I'd need a lot more context and an example to be able to evaluate if this change caused any problems.

bnjmnm’s picture

Issue tags: -Novice

No longer novice

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.