diff -u b/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js --- b/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -27,13 +27,7 @@ if (query.length >= 2) { $filter_rows.each(toggleBlockEntry); - Drupal.announce( - Drupal.formatPlural( - $table.find('tr:visible').length - 1, - '1 block is available in the modified list.', - '@count blocks are available in the modified list.' - ) - ); + Drupal.announce(Drupal.formatPlural($table.find('tr:visible').length - 1, '1 block is available in the modified list.', '@count blocks are available in the modified list.')); } else { $filter_rows.each(function (index) { $(this).parent().parent().show(); @@ -64 +58 @@ -}(jQuery, Drupal, Drupal.debounce)); \ No newline at end of file +})(jQuery, Drupal, Drupal.debounce); \ No newline at end of file reverted: --- b/core/modules/block/js/block.js +++ a/core/modules/block/js/block.js @@ -144,4 +144,4 @@ }); } }; +})(jQuery, window, Drupal); \ No newline at end of file -})(jQuery, window, Drupal); diff -u b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php --- b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php +++ b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\block\FunctionalJavascript; +use Behat\Mink\Element\NodeElement; use Drupal\FunctionalJavascriptTests\JavascriptTestBase; /** @@ -40,18 +41,17 @@ // Find the block filter field on the add-block dialog. $page->find('css', '#edit-blocks-region-header-title')->click(); - $assertSession->assertWaitOnAjaxRequest(); - $filter = $page->find('css', '.block-filter-text'); + $filter = $assertSession->waitForElement('css', '.block-filter-text'); // Get all block rows, for assertions later. $block_rows = $page->findAll('css', '.block-add-table tbody tr'); // Test block filter reduces the number of visible rows. $filter->setValue('ad'); - $session->wait(1000, 'jQuery("#drupal-live-announce").html().indexOf("blocks are available") > -1'); + $session->wait(10000, 'jQuery("#drupal-live-announce").html().indexOf("blocks are available") > -1'); $visible_rows = $this->filterVisibleElements($block_rows); if(count($block_rows)>0) { - self::assertNotEquals(count($block_rows), count($visible_rows)); + $this->assertNotEquals(count($block_rows), count($visible_rows)); } // Test Drupal.announce() message when multiple matches are expected. @@ -62,7 +62,7 @@ $filter->setValue('Powered by'); $session->wait(1000, 'jQuery("#drupal-live-announce").html().indexOf("block is available") > -1'); $visible_rows = $this->filterVisibleElements($block_rows); - self::assertEquals(1, count($visible_rows)); + $this->assertEquals(1, count($visible_rows)); $expected_message = '1 block is available in the modified list.'; $assertSession->elementTextContains('css', '#drupal-live-announce', $expected_message); @@ -70,7 +70,7 @@ $filter->setValue('Pan-Galactic Gargle Blaster'); $session->wait(1000, 'jQuery("#drupal-live-announce").html().indexOf("0 blocks are available") > -1'); $visible_rows = $this->filterVisibleElements($block_rows); - self::assertEquals(0, count($visible_rows)); + $this->assertEquals(0, count($visible_rows)); $expected_message = '0 blocks are available in the modified list.'; $assertSession->elementTextContains('css', '#drupal-live-announce', $expected_message); } only in patch2: unchanged: --- a/core/modules/block/js/block.admin.es6.js +++ b/core/modules/block/js/block.admin.es6.js @@ -3,7 +3,7 @@ * Block admin behaviors. */ -(function ($, Drupal) { +(function ($, Drupal, debounce) { 'use strict'; @@ -56,6 +56,13 @@ // Filter if the length of the query is at least 2 characters. if (query.length >= 2) { $filter_rows.each(toggleBlockEntry); + Drupal.announce( + Drupal.formatPlural( + $table.find('tr:visible').length - 1, + '1 block is available in the modified list.', + '@count blocks are available in the modified list.' + ) + ); } else { $filter_rows.each(function (index) { @@ -66,7 +73,7 @@ if ($table.length) { $filter_rows = $table.find('div.block-filter-text-source'); - $input.on('keyup', filterBlockList); + $input.on('keyup', debounce(filterBlockList, 200)); } } }; @@ -94,4 +101,4 @@ } }; -}(jQuery, Drupal)); +}(jQuery, Drupal, Drupal.debounce));