Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(facets): add a new option "facetOrdering" to Menu, RefinementList & HierarchicalMenu #3067

Merged
merged 2 commits into from Jul 5, 2021

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jun 25, 2021

If facetOrdering is enabled (the default behaviour), before the default sortBy is used, the result from renderingContent.facetOrdering.values is first checked. If that's present, it will be used to sort the items.

You can still change that ordering afterwards with the existing transformItems, so if you are sorting in transformItems, you actually override the sorting done by facet ordering, and won't see the effect. To use facetOrdering, you thus need to remove any sorting done in transformItems.

If there is a facetOrdering present in the index, but you don't want to use it for a certain widget, you need to explicitly pass facetOrdering: false to the widget or connector

References:

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 25, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit cc6f07c:

Sandbox Source
react-instantsearch-app Configuration
routing-basic Configuration

@algobot
Copy link
Contributor

algobot commented Jun 25, 2021

✔️ Deploy Preview for react-instantsearch ready!

🔨 Explore the source changes: cc6f07c

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-instantsearch/deploys/60deb8c2afae78000740d2ba

😎 Browse the preview: https://deploy-preview-3067--react-instantsearch.netlify.app

@eunjae-lee
Copy link
Contributor

sorry, i'll review this tomorrow morning!

Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me 🙌🏻

…mentList & HierarchicalMenu

If `facetOrdering` is enabled (the default behaviour), before the default sortBy is used, the result from renderingContent.facetOrdering.values is first checked. If that's present, it will be used to sort the items.

You can still change that ordering afterwards with the existing transformItems, so if you are sorting in transformItems, you actually override the sorting done by facet ordering, and won't see the effect. To use facetOrdering, you thus need to remove any sorting done in transformItems.

If there is a facetOrdering present in the index, but you don't want to use it for a certain widget, you need to explicitly pass `facetOrdering: false` to the widget or connector

References:
- [RFC 45](https://github.com/algolia/instantsearch-rfcs/blob/master/accepted/flexible-facet-values.md)
- algolia/instantsearch#4784
- algolia/algoliasearch-helper-js#822
@Haroenv Haroenv merged commit 731d9ba into master Jul 5, 2021
@Haroenv Haroenv deleted the feat/facet-ordering-values branch July 5, 2021 12:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants