Avoid refinements "jump" when using useCurrentRefinements #5794
Unanswered
javierdebug
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The refinements are grouped, so there's no way to reconstruct an ordering by time, I could imagine you flatten the items, compare with the previous items and then add any new items at the end, although I'm not sure if your users will like this more than a predictable ordering? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using the hook 'useCurrentRefinements' in a Next (React) component as:
const currentRefinements = useCurrentRefinements();
Then, I'm using the
currentRefinements.items
and mapping everyrefinement
inside that array to display the refinements somewhere on the page, so the user can easily remove any of them.The issue is that I have different refinements, so say the items array at some point is:
Then, if the user adds a new refinement, it could be:
The first object in the
refinements.items
has grown, so that refinement will get added first in the section, making the rest of the refinements "jump" to make space for the newly added one. Is there a way to keep the refinements added as they are clicked, or is there a way to order the refinements flat that doesn't change the order?If you can point me to a similar issue/discussion or any ideas, that would be helpful. Thank you in advanced
Beta Was this translation helpful? Give feedback.
All reactions