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

throttleMs behavior: Immediate first input creates edge case for minimum input validation #713

Closed
RomkaLTU opened this issue Oct 26, 2024 · 2 comments

Comments

@RomkaLTU
Copy link

RomkaLTU commented Oct 26, 2024

Context

What's your version of nuqs?

"nuqs": "^2.0.4",

What framework are you using?

  • ✅ Next.js (app router)

Which version of your framework are you using?

NextJS 14.2.15

Description

The throttleMs functionality is kind of strange. It will capture the first input instantaneously and then throttle according to the throttleMs parameter. That's pretty much it. This requires additional logic, for example, if you don't want to allow searching with just 1 letter.

@RomkaLTU RomkaLTU added the bug Something isn't working label Oct 26, 2024
@RomkaLTU
Copy link
Author

In general, this throttleMs is not good for search text input. If you try to type, the second letter will be skipped. For example, if you try to type 'hello', it will appear as 'hllo'."

@franky47
Copy link
Member

Yes, this is the expected behaviour for throttling: the URL is regularly updated, with an instant initial update.

While this works well for low-frequency UI elements like tabs or check boxes, high frequency ones (and particularly search) would benefit better from a debounce behaviour, where the update is eventually sent after a period of inactivity.

Debounce support is on the roadmap and should land soon, see #291.

@franky47 franky47 removed the bug Something isn't working label Oct 26, 2024
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

No branches or pull requests

2 participants