For the Facet dropdown widget, if there is an option who's raw value contains an apostrophe, a javascript error is thrown when selected.
As an example, consider the following option values:
- Revlon
- Olay
- L'Oreal
When L'Oreal is selected, a javascript error will be thrown: Uncaught Error: Syntax error, unrecognized expression: [data-drupal-facet-item-id='L'Oreal'].
This occurs, in our situation, in a Search API Solr stack, with the related field data type set to "Text". I presume it could happen in any instance where the raw dropdown option values have any invalid css or data attribute value. Drupal core offers the Html::getClass()
method that can be leveraged when assigning the data-drupal-facet-item-id attribute to strip out unwanted elements.
The data-drupal-facet-item-value attribute does not seem to be affected by an invalid css/data attribute value, in that it is not used in dropdown-widget.js.
This issue was previously referenced in #2995304: Dropdown facet where raw value contains apostrophe, however, the proposed solution there has no affect for us.
Comment | File | Size | Author |
---|---|---|---|
#7 | facets-dropdown-widget-with-apostrophe-3049491-7-d8.patch | 960 bytes | visabhishek |
#3 | facets-dropdown-widget-with-apostrophe-3049491-3-d8.patch | 960 bytes | coderdan |
Comments
Comment #2
coderdan CreditAttribution: coderdan at Phase2 commentedComment #3
coderdan CreditAttribution: coderdan at Phase2 commentedComment #4
recrit CreditAttribution: recrit commentedComment #5
borisson_Comment #6
borisson_Actually, this doesn't apply anymore.
Comment #7
visabhishek CreditAttribution: visabhishek as a volunteer and for Melity commentedJust rerolled the patch.
Comment #9
borisson_Thank you, committed and pushed.