Hello,

I have a feature request for views & facets.

Problem/Motivation

I have a view with products (my items) and a pager.

This view is filtered by facets.

Now when you go to the last page of your view (let's say page 5) and then you select a facet filter =>
The page reloads (if you didn't enable AJAX) with ?page=5&facet_id=22.

The problem is you don't see any results because you are still on page 5 and most likely there will be less results.

Remaining tasks

Could you give me some ideas on how this issue could be solved.

I will report back if I have some more time to investigate.

Comments

Mschudders created an issue. See original summary.

MustangGB’s picture

Project: Views » Drupal core
Version: 8.x-3.x-dev » 8.4.x-dev
Component: Code » views.module
tom3b’s picture

Having exactly the same issue. I would describe this as a bug rather than a feature request though!

The facet links should not include the page parameter.

akozma’s picture

I have the same issue, debugging the code I found the following:

The issue comes from the Drupal\facets\Plugin\facets\url_processor::buildUrls() line 133

 // Grab any route params from the original request.
      $routeParameters = Url::createFromRequest($this->request)
        ->getRouteParameters();
      if (!empty($routeParameters)) {
        $url->setRouteParameters($routeParameters);
      }

where by calling the Url::createFromRequest($this->request) it will trigger the calls in the following order

  1. Url::createFromRequest($request)
  2. \Drupal::service('router.no_access_checks')->matchRequest($request)
  3. $collection = $this->getInitialRouteCollection($request);
  4. $this->routeProvider->getRouteCollectionForRequest($request)
  5. $request->query->replace($cached->data['query']);

=> Before the calls the request doesn't contains the "page" query parameter. The request query parameters are replaced by the value loaded from the cache.

I'll check for a possible solution but having this hint someone may have a quick fix.

akozma’s picture

Project: Drupal core » Facets
Version: 8.4.x-dev » 8.x-1.x-dev
Component: views.module » Code
Category: Feature request » Bug report

Moved to the Facets issue queue.

borisson_’s picture

Issue tags: -facets, -views, -pager

This should already be fixed, see #2898189: Facet links should be page-less, there was also #2726455: QueryString URL processor breaks pagination for views displayed on the same page that actually resets the page parameter. I'm not sure what the actual behavior is supposed to be right now.

Can you reproduce this with the last dev release?

akozma’s picture

You are right borisson_, I just tested and the issue is fixed in the dev release.

Thanks.

akozma’s picture

Status: Active » Fixed

As we have the solution, I think we can close this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.