React-instantsearch: Snippet white space characters

Created on 13 Sep 2017  Â·  3Comments  Â·  Source: algolia/react-instantsearch

On using the <Snippet> element, I end up having some leading and/or trailing white spaces. On the screenshot below, the “what” is a bit shifted to the right:

screen shot 2017-09-13 at 18 17 29

In that example, when inspecting the code, I actually have a line break character at the very beginning of the text (this is copy pasted):

<span class="ais-Highlight"><span class="ais-Highlight__nonHighlighted">
What about setting up a call this week to</span></span>

Not sure if bug, or feature request, but it would be nice to apply a trim() around the value. Having investigated a bit, that solution seems quite touchy because it needs to edit the Highlither.js component which is also used by <Highlight> widget, that you might not want to get involved. trim() also must affect the white spaces between words.

Or maybe this is not related to React-IS and it happens because of my attribute value set up in the Algolia Index? Or due to the “snippet” feature of Algolia?

Most helpful comment

I'm closing this as it will be on the user side like @Haroenv mention and as we've seen with @noclat

The connector to use is connectHighlight (which is used for both the Highlight and Snippet widgets). See here: https://community.algolia.com/react-instantsearch/connectors/connectHighlight.html

All 3 comments

The record actually has a line break:

screen shot 2017-09-13 at 18 35 42

In this case, you’ll be able to use connectSnippet and trim() the value

I'm closing this as it will be on the user side like @Haroenv mention and as we've seen with @noclat

The connector to use is connectHighlight (which is used for both the Highlight and Snippet widgets). See here: https://community.algolia.com/react-instantsearch/connectors/connectHighlight.html

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vinhlh picture vinhlh  Â·  5Comments

rtman picture rtman  Â·  5Comments

noclat picture noclat  Â·  3Comments

denkristoffer picture denkristoffer  Â·  4Comments

markmiller21 picture markmiller21  Â·  3Comments