diff --git a/core/modules/views/src/Plugin/views/display/Block.php b/core/modules/views/src/Plugin/views/display/Block.php index b35ab8a80e..4a694cc08e 100644 --- a/core/modules/views/src/Plugin/views/display/Block.php +++ b/core/modules/views/src/Plugin/views/display/Block.php @@ -357,13 +357,10 @@ public function preBlockBuild(ViewsBlock $block) { } /** - * Block views use exposed widgets only if AJAX is set. + * {@inheritdoc} */ - public function usesExposed() { - if ($this->ajaxEnabled()) { - return parent::usesExposed(); - } - return FALSE; + public function usesExposedFormInBlock() { + return TRUE; } /** diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml index df70195dd8..cf47820f66 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_exposed_block.yml @@ -59,3 +59,20 @@ display: display_title: Page id: page_1 position: 0 + block_1: + display_plugin: block + id: block_1 + display_title: Block + position: 2 + display_options: + display_extenders: { } + exposed_block: true + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url.query_args + - 'user.node_grants:view' + - user.permissions + tags: { } diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 53a0e4dda7..ab271b43dc 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -193,12 +193,14 @@ public function testResetButton() { /** * Tests the exposed block functionality. + * + * @dataProvider providerTestExposedBlock */ - public function testExposedBlock() { + public function testExposedBlock($display) { $this->drupalCreateContentType(['type' => 'page']); $view = Views::getView('test_exposed_block'); - $view->setDisplay('page_1'); - $block = $this->drupalPlaceBlock('views_exposed_filter_block:test_exposed_block-page_1'); + $view->setDisplay($display); + $block = $this->drupalPlaceBlock('views_exposed_filter_block:test_exposed_block-' . $display); // Set label to display on the exposed filter form block. $block->getPlugin()->setConfigurationValue('label_display', TRUE); @@ -248,6 +250,19 @@ public function testExposedBlock() { } } + /** + * Data provider for testing different types of displays. + * + * @return array + * Array of display names to test. + */ + public function providerTestExposedBlock() { + return [ + 'page_display' => ['page_1'], + 'block_display' => ['block_1'], + ]; + } + /** * Test the input required exposed form type. */