I was looking into why labels weren't working in Sapientia and noticed that the UUIDs FacetListsGrouped was passing to my resolveLabel prop were missing their final character. Going up the stack to react-components, I think I found where the issue is coming from.
getFieldId uses the substring method to separate a field UUID from its parent model's UUID:
if (value.includes(ATTRIBUTE_DELIMITER)) {
value = value.substring(value.indexOf(ATTRIBUTE_DELIMITER) + 1, value.length - 1);
}
The substring here ends at value.length - 1. This would be the correct way to look up the last item in an array by index, but substring's second argument is exclusive, not inclusive, so the string slice stops beforevalue.length - 1, leaving off the last character.
Correcting this bug should be as simple as changing value.length - 1 to just value.length.
I was looking into why labels weren't working in Sapientia and noticed that the UUIDs
FacetListsGrouped
was passing to myresolveLabel
prop were missing their final character. Going up the stack toreact-components
, I think I found where the issue is coming from.getFieldId
uses thesubstring
method to separate a field UUID from its parent model's UUID:The substring here ends at
value.length - 1
. This would be the correct way to look up the last item in an array by index, butsubstring
's second argument is exclusive, not inclusive, so the string slice stops beforevalue.length - 1
, leaving off the last character.Correcting this bug should be as simple as changing
value.length - 1
to justvalue.length
.(See https://github.com/performant-software/react-components/blob/master/packages/core-data/src/utils/Typesense.js#L110)