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

change the score function to prevent drag #325

Merged
merged 4 commits into from
Aug 16, 2023
Merged

Conversation

steveoni
Copy link
Contributor

this pr is a propose solution to fix the drag/slow issue base on this #279 #252

@vercel
Copy link

vercel bot commented Jul 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kbar ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2023 9:51pm

Copy link
Owner

@timc1 timc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @steveoni! FYI typing anything in the search input causes the site to crash.

@steveoni
Copy link
Contributor Author

@timc1 i will test it now.

i just copied the code I updated from work and edit directly on github and push. i will update you once I fix that. FYI that's what we are using here https://www.datopian.com/

@steveoni
Copy link
Contributor Author

@timc1 is actually a small fix. now working without crashing the page

includeScore: true,
includeMatches: true,
threshold: 0.2,
minMatchCharLength: 2,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just keep this at 1 – it's kinda weird to type a single character and see the results disappear until we type once more.

package.json Outdated
@@ -60,6 +60,7 @@
"@radix-ui/react-portal": "^1.0.1",
"command-score": "^0.1.2",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this and rerun npm install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timc1 done

@rareyesdev
Copy link

rareyesdev commented Aug 14, 2023

Thank you both for following up on this issue. I was debugging this myself. I'm adding a profiler screenshot proving that command-score is the culprit.

✅ It seems that fusejs won't get stuck anymore (as the search terms grow).

@timc1 Will this fix hit pliny automatically? I would like to get this fix in my blog.

image

@timc1
Copy link
Owner

timc1 commented Aug 14, 2023

Hey @rareyesdev! I'll get this update merged in soon; want to look at the configs a little more prior. You will just need to install the latest version once I get it released :)

@timc1 timc1 merged commit 3f2b2a7 into timc1:main Aug 16, 2023
1 check passed
return str.split(/[\s\-,.!()]+/).filter(Boolean);
},
};
const fuse = new Fuse(filtered, fuseOptions);
Copy link
Sponsor Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to move this inside the useMemo and only create a new fuse instance when filtered changes? It's essentially rebuilding the search index on every render

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah #329

@timc1 timc1 mentioned this pull request Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants