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.

Comments

coderdan created an issue. See original summary.

coderdan’s picture

Issue summary: View changes
coderdan’s picture

recrit’s picture

Status: Active » Needs review
borisson_’s picture

Status: Needs review » Reviewed & tested by the community
borisson_’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Actually, this doesn't apply anymore.

visabhishek’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new960 bytes

Just rerolled the patch.

  • borisson_ committed da77501 on 8.x-1.x authored by coderdan
    Issue #3049491 by coderdan, visabhishek, borisson_: Dropdown widget...
borisson_’s picture

Status: Needs review » Fixed

Thank you, committed and pushed.

Status: Fixed » Closed (fixed)

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