Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | facets_dropdown_quote_raw_value-3080593-2.patch | 747 bytes | DuaelFr |
Comments
Comment #2
DuaelFrComment #3
dermarioI 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.
Comment #5
borisson_This change seems to make sense, committed and pushed. Thanks!