Problem/Motivation

Facet raw value is used as item id in the data-drupal-facet-item-id HTML attribute. The dropdown widget tries to match this data attribute to get the link to enable the facet.

If the facet raw value contains a single or double quote, the change.facets event in js/dropdown-widget.js fails and the facet cannot be selected.

For example:

  • Facet value: Certif'Région
  • JS error when selecting the facet: Uncaught Error: Syntax error, unrecognized expression: [data-drupal-facet-item-id='organization_label_organization_card-Certif'Région']

Proposed resolution

Replace single and double quotes by dashes when generating the item id.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DuaelFr created an issue. See original summary.

DuaelFr’s picture

Status: Active » Needs review
FileSize
747 bytes
dermario’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the bug is there and the patch fixes the problem. With anonymous users facetting works fine but if i'm logged in, i get errors likes these:

Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '[data-drupal-link-system-path="search/content"]:not([hreflang])[data-drupal-link-query='{"f":["facet:Certif'Région"],"keys":"Form"}'],[data-drupal-link-system-path="search/content"][hreflang="en"][data-drupal-link-query='{"f":["facet:Certif'Région"],"keys":"Form"}']' is not a valid selector.

I think this is related caused by #2902769: active-link.js throws JS error if query string parameter contains a single quote and needs to get fixed in core - so from my point of view this is RTBC.

  • borisson_ committed b94c580 on 8.x-1.x authored by DuaelFr
    Issue #3080593 by DuaelFr: Cannot select a facet if raw value contains...
borisson_’s picture

Status: Reviewed & tested by the community » Fixed

This change seems to make sense, committed and pushed. Thanks!

Status: Fixed » Closed (fixed)

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