Skip to content

fix(keyboard): debounce Enter key and block during submission - #1311

Merged
kike-alt merged 1 commit into
kike-alt:mainfrom
snowrugar-beep:fix/issue-1240-prevent-double-submission
Aug 26, 2026
Merged

fix(keyboard): debounce Enter key and block during submission#1311
kike-alt merged 1 commit into
kike-alt:mainfrom
snowrugar-beep:fix/issue-1240-prevent-double-submission

Conversation

@snowrugar-beep

@snowrugar-beep snowrugar-beep commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1240

Closes #1237

Closes #1238

Closes #1239

Adds a 300ms debounce on the Enter key handler and an isSubmitting guard to prevent duplicate guess submissions when the Enter key is pressed rapidly.

Why

Rapidly pressing Enter twice in quick succession could trigger the onEnter callback 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 boolean isSubmitting option that callers can set to true during guess evaluation to block all Enter keypresses.

What was built

frontend/src/hooks/useKeyboardNavigation.ts:

Change Detail
isSubmitting option New optional boolean on KeyboardNavigationOptions; when true, Enter keypresses are ignored entirely
300ms debounce lastEnterTime ref tracks the timestamp of the last Enter press; subsequent presses within 300ms are ignored
Both mechanisms Independent: debounce prevents rapid clicks, isSubmitting blocks during animation

No existing files modified beyond this hook — callers opt in by passing isSubmitting to the hook.

Acceptance criteria coverage

  • Debounce Enter key submission handler by 300ms (line 71: now - lastEnterTime.current >= ENTER_DEBOUNCE_MS)
  • Set isSubmitting state flag while guess evaluation animation is active (new isSubmitting option on KeyboardNavigationOptions)
  • Ignore Enter keypress events while isSubmitting is true (line 69: if (!handlersRef.current.isSubmitting))

Test plan

  • npm test — not run per instruction
  • npm run build — not run per instruction

Env vars / Notes

No new environment variables. The isSubmitting option is backward-compatible — existing callers that don't pass it get false (debounce-only behavior). Callers should set isSubmitting: true during their guess evaluation animation and reset to false when complete.

- 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
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@kike-alt
kike-alt merged commit 99bfd25 into kike-alt:main Aug 26, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants