-
Notifications
You must be signed in to change notification settings - Fork 507
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
Highlight arrays #1932
Comments
Thanks @bitblitter for opening the issue here! this follow this discussion: https://discourse.algolia.com/t/react-instantsearch-highlight-on-field-with-array-value/469. |
Really looking forward to this feature too! 😃 With the help of @mikaa123, we came up with this workaround that doesn't need to change the highlighting tags: const highlightedAttr = hit._highlightResult.array_attr
.map(attr => attr.value)
.map(attr => attr.replace(/<ais-highlight-[0-9]+/, '<em class="ais-Highlight__highlighted"').replace(/<\/ais-highlight-[0-9]+/, '</em'))
.join(', ') and then: <span dangerouslySetInnerHTML={{__html: highlightedAttr}} /> |
React InstantSearch has been moved here: https://github.com/algolia/react-instantsearch |
Do you want to request a feature or report a bug?
This is a feature request.
Feature: What is your use case for such a feature?
This feature would enable highlighting for arrays of strings.
In my specific case, I wanted to display the values separated by a comma, and highlight the matching terms.
Feature: What is your proposed API entry? The new option to add? What is the behavior?
Enable the Highlight component to be able to display string arrays, with an optional separator.
What project are you opening an issue for?
What is the version you are using? Always use the latest one before opening a bug issue.
I'm using the last version on npm: react-instantsearch ^2.2.5
The text was updated successfully, but these errors were encountered: