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

Adjacent active chunks are handled as a single chunk #68

Open
grigasp opened this issue Dec 4, 2018 · 2 comments
Open

Adjacent active chunks are handled as a single chunk #68

grigasp opened this issue Dec 4, 2018 · 2 comments

Comments

@grigasp
Copy link

grigasp commented Dec 4, 2018

See this example: https://codesandbox.io/s/7j2njo9l2q.

searchWords={["e"]}
textToHighlight="sleep"
activeIndex={0} 

highlights both ee instead of just the first e. With activeIndex={1} nothing gets highlighted.

@bvaughn
Copy link
Owner

bvaughn commented Dec 4, 2018

Interesting. Looks like this is due to the [highlight-words-core combineChunks method joining the adjacent chunks before returning them.

I haven't thought about this code in a long time, but my initial thoughts are that the easiest way to fix this would probably be to tell highlight-words-core not to combine chunks if an activeIndex value is provided. Probably the easiest way to do that is to just pass a no-op findChunks param to highlight-words-core.

Interested in contributing a PR that does something like this?

@bigappleinsider
Copy link
Contributor

Here's a demo of the issue:

https://codesandbox.io/s/14nx7w1404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants