diff -u b/core/modules/views/src/Form/ViewsExposedForm.php b/core/modules/views/src/Form/ViewsExposedForm.php --- b/core/modules/views/src/Form/ViewsExposedForm.php +++ b/core/modules/views/src/Form/ViewsExposedForm.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Path\CurrentPathStack; use Drupal\Core\Render\Element\Checkboxes; use Drupal\Core\Url; use Drupal\views\ExposedFormCache; @@ -22,21 +23,35 @@ */ protected $exposedFormCache; + + /** + * The current path stack. + * + * @var \Drupal\Core\Path\CurrentPathStack + */ + protected $currentPathStack; + /** * Constructs a new ViewsExposedForm * * @param \Drupal\views\ExposedFormCache $exposed_form_cache * The exposed form cache. + * @param \Drupal\Core\Path\CurrentPathStack $current_path_stack + * The current path stack. */ - public function __construct(ExposedFormCache $exposed_form_cache) { + public function __construct(ExposedFormCache $exposed_form_cache, CurrentPathStack $current_path_stack) { $this->exposedFormCache = $exposed_form_cache; + $this->currentPathStack = $current_path_stack; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('views.exposed_form_cache')); + return new static( + $container->get('views.exposed_form_cache'), + $container->get('path.current') + ); } /** @@ -120,8 +135,7 @@ } else { // Instead set the action to the page we were on. - $referer = $this->getRequest()->headers->get('referer'); - $form_action = parse_url($referer, PHP_URL_PATH); + $form_action = $this->currentPathStack->getPath(); } } else { diff -u b/core/modules/views/tests/src/FunctionalJavascript/BlockExposedFilterAJAXTest.php b/core/modules/views/tests/src/FunctionalJavascript/BlockExposedFilterAJAXTest.php --- b/core/modules/views/tests/src/FunctionalJavascript/BlockExposedFilterAJAXTest.php +++ b/core/modules/views/tests/src/FunctionalJavascript/BlockExposedFilterAJAXTest.php @@ -61,6 +61,7 @@ // Filter by page type. $this->submitForm(['type' => 'page'], t('Apply')); $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertSession()->waitForElementRemoved('xpath', "//text()[normalize-space() = 'Article A']"); // Verify that only the page nodes are present. $html = $page->getHtml(); only in patch2: unchanged: --- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php @@ -72,6 +72,32 @@ public function waitForElement($selector, $locator, $timeout = 10000) { } /** + * Looks for the specified selector and returns TRUE when it is unavailable. + * + * @param string $selector + * The selector engine name. See ElementInterface::findAll() for the + * supported selectors. + * @param string|array $locator + * The selector locator. + * @param int $timeout + * (Optional) Timeout in milliseconds, defaults to 10000. + * + * @return bool + * TRUE if not found, FALSE if found. + * + * @see \Behat\Mink\Element\ElementInterface::findAll() + */ + public function waitForElementRemoved($selector, $locator, $timeout = 10000) { + $page = $this->session->getPage(); + + $result = $page->waitFor($timeout / 1000, function() use ($page, $selector, $locator) { + return !$page->find($selector, $locator); + }); + + return $result; + } + + /** * Waits for the specified selector and returns it when available and visible. * * @param string $selector