diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index f28ccabdd88..0fda8087489 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -483,18 +483,18 @@ * An array of all the filterable options. */ getOptions: function ($allOptions) { - var $label; + var $title; var $description; var $option; var options = []; var length = $allOptions.length; for (var i = 0; i < length; i++) { $option = $($allOptions[i]); - $label = $option.find('label'); + $title = $option.find('.title'); $description = $option.find('.description'); options[i] = { - // Search on the lowercase version of the label text + description. - searchText: $label.text().toLowerCase() + ' ' + $description.text().toLowerCase(), + // Search on the lowercase version of the title text + description. + searchText: $title.text().toLowerCase() + ' ' + $description.text().toLowerCase(), // Maintain a reference to the jQuery object for each row, so we don't // have to create a new object inside the performance-sensitive keyup // handler. diff --git a/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.info.yml b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.info.yml new file mode 100644 index 00000000000..2a4ed8dbef9 --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.info.yml @@ -0,0 +1,8 @@ +name: 'Views test field' +type: module +description: 'Add custom global field for testing purposes.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - views_ui diff --git a/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.module b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.module new file mode 100644 index 00000000000..3d1ac8f6f96 --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.module @@ -0,0 +1,18 @@ + t('Views test field 1 - FIELD_1_TITLE'), + 'help' => t('Field 1 for testing purposes - FIELD_1_DESCRIPTION'), + 'field' => [ + 'id' => 'views_test_field_1', + ], + ]; + $data['views']['views_test_field_2'] = [ + 'title' => t('Views test field 2 - FIELD_2_TITLE'), + 'help' => t('Field 2 for testing purposes - FIELD_2_DESCRIPTION'), + 'field' => [ + 'id' => 'views_test_field_2', + ], + ]; + + return $data; +} diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php new file mode 100644 index 00000000000..32b1a400cb7 --- /dev/null +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php @@ -0,0 +1,76 @@ +drupalCreateUser([ + 'administer views', + ]); + $this->drupalLogin($admin_user); + } + + /** + * Tests filtering options in the 'Add fields' dialog. + */ + public function testFilterOptionsAddFields() { + $this->drupalGet('admin/structure/views/view/content'); + + $session = $this->getSession(); + $web_assert = $this->assertSession(); + $page = $session->getPage(); + + // Open the dialog. + $page->clickLink('views-add-field'); + + // Wait for the popup to open and the search field to be available. + $options_search = $web_assert->waitForField('override[controls][options_search]'); + + // Test that the both special fields are visible. + $this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible()); + $this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible()); + + // Test the ".title" field in search. + $options_search->setValue('FIELD_1_TITLE'); + $page->waitFor(10, function () use ($page) { + return !$page->findField('name[views.views_test_field_2]')->isVisible(); + }); + $this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible()); + $this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible()); + + // Test the ".description" field in search. + $options_search->setValue('FIELD_2_DESCRIPTION'); + $page->waitFor(10, function () use ($page) { + return !$page->findField('name[views.views_test_field_1]')->isVisible(); + }); + $this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible()); + $this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible()); + + // Test the "label" field not in search. + $options_search->setValue('FIELD_1_LABEL'); + $page->waitFor(10, function () use ($page) { + return !$page->findField('name[views.views_test_field_2]')->isVisible(); + }); + $this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible()); + $this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible()); + } + +}