diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index d986a97d0574c77344722e1eaaa211c7720317d7..ec4808deae932eeb5469a9425b34c182dc42e0a4 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -322,7 +322,12 @@ public function resetForm(&$form, FormStateInterface $form_state) { if (isset($views_session[$this->view->storage->id()][$display_id])) { unset($views_session[$this->view->storage->id()][$display_id]); } - $session->set('views', $views_session); + if (!empty($views_session)) { + $session->set('views', $views_session); + } + else { + $session->remove('views'); + } // Set the form to allow redirect. if (empty($this->view->live_preview) && !\Drupal::request()->isXmlHttpRequest()) { diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index fa9995eea82ee2e04fe4756b14cbeaaf8df4372a..7d2af0f1a4dd3a42f2a423168756e9ef2e2036d4 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -209,10 +209,13 @@ public function testResetButton(): void { $this->assertSession()->fieldValueEquals('edit-type', 'article'); // Test the reset works. - $this->drupalGet('test_exposed_form_buttons', ['query' => ['op' => 'Reset']]); + $this->submitForm([], 'Reset'); + $this->assertSession()->addressEquals('test_exposed_form_buttons'); $this->assertSession()->statusCodeEquals(200); // Test the type has been reset. $this->assertSession()->fieldValueEquals('edit-type', 'All'); + // Test that the reset button didn't start a session. + $this->assertEquals(FALSE, (bool) $this->getSession()->getCookie($this->getSessionName())); // Test the button is hidden after reset. $this->assertSession()->fieldNotExists('edit-reset');