2

SXA Checlikst filter is not working when filtering by a choice with a special character like : '&' then filter by other filter

enter image description here

I think the problem is in the encoding because when I checked the Url the first choice was not right :

Blockquote https://my_instance_name//sxa/search/results/?l=en&s={57C05478-9434-4B19-BD13-F4C248DB8AF6}&itemid={E089DD6D-ECFB-4C8D-AF7E-A4CEF507D92F}&sig=SearchResults1&relatedaspectoflifesearchable=Business%20Library%20&templatedisplayname=Service%20Subtopic&e=0&q=&p=10&v={8D1038ED-B68C-4D02-B5D4-430F30288136}

If you notice in the Url there is only : Business%20Library%20

If I write : Business%20Library%20%26%20Directory, It works successfullt

3
  • You should open a ticket with Sitecore Support. This is probably a bug in the javascript for the checkbox filter (there are a few in that one). – Gatogordo Sep 4 '18 at 12:24
  • @Mohamed Mosa: Which version of SXA are you using? I've just tested your case quickly and I added such value: "Library & Directory" to my items. When I start filtering by it, it's what I've in the URL "myfield=library%20%26%20directory" and it's filtering correctly results. – Dawid Rutkowski Sep 4 '18 at 14:24
  • I'm using SXA 1.7, it's working correctly I know, I'm talking in case there are two checklist filters, when I filter by the second filter after I filtered by the first, This case happens, it happens when appending other parameter to the URL – Mohamed Mosa Sep 4 '18 at 14:46
3

I did a small investigation and it's actually a bug in front-end part of SXA search logic.

If this is a blocker for you then you could apply following changes to make Checklist Filter work:

  • component-search-query.js - replace item with encodeURIComponent(item) in updateHash() function

    enter image description here

  • component-search-results-filter.js - replace facetValue = currentFacet.data('facetvalue') with facetValue = decodeURIComponent(currentFacet.data('facetvalue')) in updateFacet() function: enter image description here

You will find both scripts under /sitecore/media library/Base Themes/SearchTheme.

Important! This is not an official fix, I've not tested it fully and with other search renderings (I can imagine some potential problems). Treat it as a workaround if this bug is blocking you.

1
  • It works Thank you so much, I also have a concern, in Arabic language the checklist filter is not working at all, there is a problem with the encoding (I think the encoding happens by escape() and the decoding happens by decodeURIComponent()), the URL was : relatedaspectoflifesearchable=%u062A%u0635%u0648%u064A%u062A however after I applied the above fix for my problem, the Arabic checklist filter is not working also but with a different behavior, the URL now is : relatedaspectoflifesearchable=undefined – Mohamed Mosa Sep 6 '18 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.