Closed hieuvts closed 2 years ago
@hieuvts I've opened your sandbox and tested a few scenarios and could not reproduce the issue. I have also tested locally with no issue.
Is it possible your build did not update when you first added that entry? That could explain why it wasn't available when searching... If you continue to have this issue, try refreshing the sandbox window (to the left of the address bar) and try again.
@JordanMalan I'm sorry for didn't provide a sandbox link. Please take a look in: https://codesandbox.io/s/confident-easley-k9l83?file=/src/App.js
"John" and "Michael" are not listed in the search results. But "Oliver " (with a white space) does.
@hieuvts Hi, I found your problem, see this Sandbox
The issue is that when you have no search query, you instead query with " " a space. So all of the names that have a space are returned.
In addition, your threshold was 1.0 which is far too high as a specific query like "John" will return all results. I recommend using 0.5 so that the search works better.
I've also mapped the fuse results to match the data array's format, this is so the map at the bottom works.
@JordanMalan
Thank you for helping me solve the problem with a nice solution. It's easy to understand.
Fuse search not match if field value is only a single word.
Code:
I have to inseart a space (after a stand alone word) to make Fuse recognize it. Is it a bug or I'm using wrong Fuse search options?