Commit 64c56021 authored by recrit's avatar recrit Committed by borisson_

Issue #2898189 by recrit, borisson_: Facet links should be page-less

parent 931b351c
......@@ -138,7 +138,14 @@ class QueryString extends UrlProcessorPluginBase {
$new_url = clone $url;
if ($result_get_params->all() !== [$this->filterKey => []]) {
$new_url->setOption('query', $result_get_params->all());
$new_url_params = $result_get_params->all();
// Facet links should be page-less.
// See https://www.drupal.org/node/2898189.
unset($new_url_params['page']);
// Set the new url parameters.
$new_url->setOption('query', $new_url_params);
}
$result->setUrl($new_url);
......
......@@ -6,6 +6,7 @@ use Drupal\Core\Url;
use Drupal\facets\FacetInterface;
use Drupal\facets\Entity\Facet;
use Drupal\facets\FacetSourceInterface;
use Drupal\views\Views;
/**
* Tests the overall functionality of the Facets admin UI.
......@@ -174,4 +175,33 @@ class UrlIntegrationTest extends FacetsTestBase {
$this->assertSession()->statusCodeEquals(200);
}
/**
* Regression test for #2898189.
*
* @link https://www.drupal.org/node/2898189
*/
public function testResetPager() {
$id = 'owl';
$name = 'Owl';
$this->createFacet($name, $id);
// Set view pager option to 2 items, so we can check the pager rest on the
// facet links.
$view = Views::getView('search_api_test_view');
$view->setDisplay('page_1');
$pagerOptions = $view->display_handler->getOption('pager');
$pagerOptions['options']['items_per_page'] = 2;
$view->display_handler->setOption('pager', $pagerOptions);
$view->save();
$content_types = ['item', 'article'];
foreach ($content_types as $content_type) {
$this->drupalGet('search-api-test-fulltext');
$this->clickLink('2');
$this->assertTrue(strpos($this->getUrl(), 'page=1'));
$this->clickLink($content_type);
$this->assertFalse(strpos($this->getUrl(), 'page=1'));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment