Skip to content
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

getFieldId in TypesenseUtils truncates the last character of each field name #280

Closed
camdendotlol opened this issue May 17, 2024 · 0 comments · Fixed by #284
Closed

getFieldId in TypesenseUtils truncates the last character of each field name #280

camdendotlol opened this issue May 17, 2024 · 0 comments · Fixed by #284
Assignees
Labels
v2.2.3 Issues in v2.2.3

Comments

@camdendotlol
Copy link
Contributor

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 before value.length - 1, leaving off the last character.

Correcting this bug should be as simple as changing value.length - 1 to just value.length.

(See https://github.com/performant-software/react-components/blob/master/packages/core-data/src/utils/Typesense.js#L110)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.2.3 Issues in v2.2.3
Projects
None yet
2 participants