FacetedSearch not working with special character


Having problem with filtering products
When selecting brands the url keeps adding with additional brand to the url, as showed below:


And if the brand has special character “&” (Count & Countess), the search doesn’t work, it just keeps adding the brand to the url:


Is it a bug?
Thanks in advanced.

Litium version: 7.2

This is a bug, please report this in the Docs.

A workaround could be to change FacetedSearch.action.js and use encodeURIComponent on group.id and val in toFilterCriteria.

const toFilterCriteria = groups => groups
    .map(group => group.selectedOptions
        .filter(val => val && val.length > 0)
        .map(val => `${encodeURIComponent(group.id)}=${encodeURIComponent(val)}`)
    .reduce((flat, current) => [...flat, ...current], []);

Since you encode the group.id as well, you need to decode the param in the submit function, otherwise it won’t remove the filter when you click it.

The entire query string will be encoded again in History.middleware.js though.

Thanks Nils, this is a working workaround.

We are currently working on just adding brands to brand parameter.


so instead for code above, it would request the code below:


It will be hard to detect if the comma delimiter in the brand is a delimiter between the brands or if the brand name contains a comma delimiter. I don’t think it will be possible in a good way to reorganizing the values like that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.