I am working on updating a locations map vertical for a client (standard map, not full page). The map has facets based on location type. The client has asked if it possible to prevent the labels / checkboxes from automatically reordering when selected. For example, initially the facet options appear with Branch Offices on top, followed by MOs, ATMs, and then Commercial (see screenshot). When selected, the lower options move to the top (see second screenshot). Is there an option we can deploy to prevent this auto-sorting?
Hi Garret! This October 2020 post about ordered facets might have the answer you’re looking for. There should be a field called
facetOrder which you can populate with an array of facets in whatever order you choose.
As noted by the post, each facet you choose to include in the facetOrder array must have
facet set to
true in your search config.
Hope this helps! I’d be happy to look into this further if the issue persists.
Hi @Jacob_Fromm - thank you so much for your speedy reply! The post you linked details ordering the facets by the fields that power them. In my case, we only have one field that powers a facet (location type), but I would like to order the options within that field (Branch office, MO, etc.). I’m not sure if this is possible, or if the auto-sorting is standard logic we cannot override. Please let me know if you have any insight into this!
Ah, I see. To customize the order of facet options, take a look at
transformFacets. Here’s a link to the Transforming Facets section of the Answers Search UI docs. According to the documentation, you should be able to control the order of facet options with some custom logic.
You can also find a brief explanation, with some examples, of how to use
transformFacets in this response to a community post from April '20.
Again, if this doesn’t solve your issue, I’d be happy to take a closer look or escalate the issue.