New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(helper): correctly set isRefined for hierarchical facet values with trailing spaces #6059
Conversation
…th trailing spaces
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 a53bae3:
|
How does this happen? can it happen for non-hierarchical facets too? seems a little odd for the place of the normalisation of the facet value to be. |
This happens because the deep equality check fails, as the current refinement part is compared against a reference that has been trimmed here: https://github.com/algolia/instantsearch/blob/master/packages/algoliasearch-helper/src/SearchResults/generate-hierarchical-tree.js#L192. Conjunctive / disjunctive facets go through another method to set their I can't see anywhere else to normalise the variable for this check, this is very specific to the hierarchical menu generation. |
Thanks, but I meant: how do you get an untrimmed facet value? |
Ah! This was discovered in a customer's dataset, one of their facet values had a trailing space. |
@Haroenv are you satisfied with the changes, can I go ahead and merge it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's a valid reason for this to exist, why not, but I would overall suggest to fix indexing first
Summary
Hierarchical facet values that have a trailing space are not correctly flagged with
isRefined: true
during the generation of the hierarchical tree. This is because its path part is compared to its name, which is trimmed by another part of the code.This PR ensures the part is also trimmed when comparing it to the name.
Result
Hierarchical facet values that are refined are marked as so by the returned data from
getFacetValues()
.Derived from CR-5241