Problem/Motivation

When the page doesn't use any filter (first load) and some facet contains an active item then all items of the next facet will be active too. It means that they will contain 'is-active' attribute class.
bug-report

Really this is an interesting bug. The list widget prepares an URL by new function getUrlForRequest() https://git.drupalcode.org/project/facets/-/blob/2.0.x/src/Plugin/facets...
And this function stores the URL object in the drupal static https://git.drupalcode.org/project/facets/-/blob/2.0.x/src/Utility/Facet...
So, what we have in the result:

  • Facet module prepares URL for the first facet item by getUrlForRequest()
  • The item is active and adds 'is-active' class attribute to the URL object.
  • The URL object wasn't cloned so the URL in the drupal static updated too
  • Facet prepares the URL for the second item by getUrlForRequest() again but now the function returns the URL with attributes from the previous facet item

Result: every facet link shares its own attributes with the next one.

Looks like it was caused by #3291943: When rendering facets on non search page, it throws error instead of 404 on 404 pages

Proposed resolution

Clone the URL as we did for the other place where we use the same function.
https://git.drupalcode.org/project/facets/-/blob/2.0.x/src/Plugin/facets...

Issue fork facets-3326234

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

HitchShock created an issue. See original summary.

hitchshock’s picture

Status: Active » Needs review
StatusFileSize
new762 bytes
hitchshock’s picture

Issue summary: View changes
hitchshock’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Can confirm this issue and the patch does fix it. Would be good to get into 2.x and 3.x

Seems small enough to not need tests.

Rajeshreeputra made their first commit to this issue’s fork.

rajeshreeputra’s picture

Created MR for ease.

ckng changed the visibility of the branch 3326234-facet-links-with to hidden.

ckng changed the visibility of the branch 3326234-facet-links-with to hidden.

ckng changed the visibility of the branch 3326234-facet-links-with to active.