itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aggregations are always ordered by selected item first

lhoucinecherif opened this issue · comments

Hi,
Can we make aggregations sorting more flexible, to prevent the selected items from going to the top of the list

here an example :

image

when I select 2022, it go to the top of the list, in my case it should stay at it initial position (ordered by terms)
image

It make some confusion for users when selecting many items :
the affected code is in the helper.js file :

if (sort === 'term') {
buckets = _.orderBy(buckets, ['selected', 'key'], ['desc', order || 'asc']);
} else {
buckets = _.orderBy(buckets, ['selected', 'doc_count', 'key'], ['desc', order || 'desc', 'asc']);
}

the 'selected' key is hard coded in this file, it should be more flexible so we can order with custom criteria , or simply remove the 'selected' param if not needed.

Thanks

Hey,

This issue is related: #39

You can make a PR which makes this behavior (selected filters on top) configurable then I'll review and merge it