Skip to content

Fix: Prevent backspace buffer re-emission in trackpad hidden input#106

Open
Rozerxshashank wants to merge 2 commits intoAOSSIE-Org:mainfrom
Rozerxshashank:fix/backspace-buffer-96
Open

Fix: Prevent backspace buffer re-emission in trackpad hidden input#106
Rozerxshashank wants to merge 2 commits intoAOSSIE-Org:mainfrom
Rozerxshashank:fix/backspace-buffer-96

Conversation

@Rozerxshashank
Copy link
Contributor

@Rozerxshashank Rozerxshashank commented Feb 17, 2026

Addressed Issues:

Fixes #96
This PR the issue where pressing the backspace key on a mobile keyboard would sometimes cause the previously typed text/buffer to be re-sent to the server instead of just deleting characters.

This was caused by the browser's native predictive text logic interacting with our onChange handler.

###Verification
Manual Test: Typed strings (e.g., "organisation") and rapidly pressed backspace on a mobile device.

Result: Server logs confirmed only backspace key events were processed, and the previous buffer was not re-emitted.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.

Summary by CodeRabbit

  • Bug Fixes
    • Improved backspace and enter key handling in the trackpad interface to prevent unintended default browser behaviors, ensuring more reliable keyboard input and preventing accidental navigation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

Warning

Rate limit exceeded

@Rozerxshashank has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The PR enhances TrackpadPage's key event handling to fix a bug where backspace sends the previous buffered input. When backspace or enter keys are detected, the code now prevents default browser behavior and clears the hidden input value before sending the key event. Other multi-character keys maintain existing behavior with explicit braces added.

Changes

Cohort / File(s) Summary
Trackpad Key Event Handling
src/routes/trackpad.tsx
Enhanced handling for backspace and enter keys to prevent default browser behavior, clear hidden input values, and properly send key events; other multi-character keys wrapped with explicit braces.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A hop, a skip, a backspace fix!
No more ghostly inputs in the mix,
The buffer clears with a gentle bound,
Key events now flow without a sound.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: preventing backspace buffer re-emission in the trackpad hidden input, which directly addresses the primary objective.
Linked Issues check ✅ Passed The code changes directly address issue #96 by preventing backspace key events from re-emitting the previous input buffer through preventDefault and input clearing.
Out of Scope Changes check ✅ Passed All changes in trackpad.tsx are directly related to fixing the backspace buffer re-emission issue; no unrelated or out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Rozerxshashank Rozerxshashank force-pushed the fix/backspace-buffer-96 branch from 61d12dc to 00dbe57 Compare February 17, 2026 10:03
@Rozerxshashank Rozerxshashank changed the title Fix/backspace buffer 96 Fix: Prevent backspace buffer re-emission in trackpad hidden input Feb 17, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/trackpad.tsx (1)

105-110: ⚠️ Potential issue | 🟡 Minor

Remove debug console.log statements.

Lines 106 and 110 contain development-time trace logs that should not ship to production. They leak internal state (modifier, buffer, combo keys) to the browser console.

🧹 Proposed fix
 const handleModifier = (key: string) => {
-    console.log(`handleModifier called with key: ${key}, current modifier: ${modifier}, buffer:`, buffer);
-    
     if (modifier === "Hold") {
         const comboKeys = [...buffer, key];
-        console.log(`Sending combo:`, comboKeys);
         sendCombo(comboKeys);
         return;
     } else if (modifier === "Active") {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/trackpad.tsx` around lines 105 - 110, Remove the development
console.log traces in handleModifier: delete the console.log that prints
`handleModifier called with key: ${key}, current modifier: ${modifier}, buffer:`
and the console.log that prints `Sending combo:` before sending comboKeys; keep
the existing logic that builds comboKeys from buffer and key and the subsequent
send/dispatch behavior intact so only the debug output is removed (refer to
function handleModifier, variables modifier, buffer, and comboKeys).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/routes/trackpad.tsx`:
- Around line 105-110: Remove the development console.log traces in
handleModifier: delete the console.log that prints `handleModifier called with
key: ${key}, current modifier: ${modifier}, buffer:` and the console.log that
prints `Sending combo:` before sending comboKeys; keep the existing logic that
builds comboKeys from buffer and key and the subsequent send/dispatch behavior
intact so only the debug output is removed (refer to function handleModifier,
variables modifier, buffer, and comboKeys).

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.

[Bug]: Previous input stays after injection

1 participant