fix(keyboard): debounce Enter key and block during submission - #1311
Merged
kike-alt merged 1 commit intoAug 26, 2026
Merged
Conversation
- Add 300ms debounce on Enter key to prevent rapid double-submission - Add isSubmitting option to block Enter keypress during guess evaluation - Both mechanisms work independently: debounce prevents rapid clicks, isSubmitting prevents submission during animation Closes kike-alt#1240
|
@snowrugar-beep Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1240
Closes #1237
Closes #1238
Closes #1239
Adds a 300ms debounce on the Enter key handler and an
isSubmittingguard to prevent duplicate guess submissions when the Enter key is pressed rapidly.Why
Rapidly pressing Enter twice in quick succession could trigger the
onEntercallback twice before the guess evaluation animation completed, causing duplicate submission calls to the backend. The fix uses two independent mechanisms: a timestamp-based debounce (300ms minimum between Enter presses) and a booleanisSubmittingoption that callers can set totrueduring guess evaluation to block all Enter keypresses.What was built
frontend/src/hooks/useKeyboardNavigation.ts:isSubmittingoptionKeyboardNavigationOptions; whentrue, Enter keypresses are ignored entirelylastEnterTimeref tracks the timestamp of the last Enter press; subsequent presses within 300ms are ignoredisSubmittingblocks during animationNo existing files modified beyond this hook — callers opt in by passing
isSubmittingto the hook.Acceptance criteria coverage
now - lastEnterTime.current >= ENTER_DEBOUNCE_MS)isSubmittingoption onKeyboardNavigationOptions)if (!handlersRef.current.isSubmitting))Test plan
npm test— not run per instructionnpm run build— not run per instructionEnv vars / Notes
No new environment variables. The
isSubmittingoption is backward-compatible — existing callers that don't pass it getfalse(debounce-only behavior). Callers should setisSubmitting: trueduring their guess evaluation animation and reset tofalsewhen complete.