diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 01a11051e8..d9140adbdf 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -276,6 +276,8 @@ var group = this.$controlGroup.val(); + // Search through the search texts in the form for matching text. + var activeViews = 0; this.options.forEach(function (option) { function hasWord(word) { return option.searchText.indexOf(word) !== -1; @@ -291,9 +293,15 @@ } option.$div.toggle(found); + activeViews += found; }); $(event.target).trigger('dialogContentResize'); + + Drupal.announce( + Drupal.formatPlural(activeViews, '1 option is available in the modified list.', '@count options are available in the modified list.') + ); + } }); diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php index 32b1a400cb..dad70bc2cf 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php @@ -56,6 +56,10 @@ public function testFilterOptionsAddFields() { $this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible()); $this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible()); + // Check that the new number of rows is set by announce. + $session->wait(10000, 'jQuery("#drupal-live-announce").html().indexOf("1 option is available in the modified list.") > -1'); + $web_assert->elementTextContains('css', '#drupal-live-announce', '1 option is available in the modified list.'); + // Test the ".description" field in search. $options_search->setValue('FIELD_2_DESCRIPTION'); $page->waitFor(10, function () use ($page) { @@ -71,6 +75,13 @@ public function testFilterOptionsAddFields() { }); $this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible()); $this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible()); + + // Clear the search and see if the new number of rows is set by announce. + $options_search->setValue(''); + $block_rows = $page->findAll('css', 'tr.filterable-option'); + $block_row_count = count($block_rows); + $session->wait(10000, 'jQuery("#drupal-live-announce").html().indexOf("' . $block_row_count . ' options are available") > -1'); + $web_assert->elementTextContains('css', '#drupal-live-announce', $block_row_count . ' options are available in the modified list.'); } } diff --git a/core/modules/views_ui/views_ui.libraries.yml b/core/modules/views_ui/views_ui.libraries.yml index 44b6832abd..cc5985b026 100644 --- a/core/modules/views_ui/views_ui.libraries.yml +++ b/core/modules/views_ui/views_ui.libraries.yml @@ -7,6 +7,7 @@ views_ui.admin: dependencies: - core/jquery - core/drupal + - core/drupal.announce - core/drupalSettings - core/jquery.once - core/jquery.form