Skip to content

fix(wallet): repair the withdraw amount key filter (paste is currently blocked) - #1479

Open
rajanpanth wants to merge 1 commit into
SuperteamDAO:mainfrom
rajanpanth:fix/withdraw-amount-keydown
Open

fix(wallet): repair the withdraw amount key filter (paste is currently blocked)#1479
rajanpanth wants to merge 1 commit into
SuperteamDAO:mainfrom
rajanpanth:fix/withdraw-amount-keydown

Conversation

@rajanpanth

@rajanpanth rajanpanth commented Aug 19, 2026

Copy link
Copy Markdown

The bug

TokenAmountInput filters keystrokes on the withdraw amount field with:

!/[0-9]|\.|\.|\Backspace|Tab|\Delete|ArrowLeft|ArrowRight/.test(e.key)

This doesn't mean what it reads as. In a regex literal \B is the non-word-boundary assertion and \D is "any non-digit", so the two alternatives compile to \B + ackspace and \D + elete. They match those key names by accident. The pattern is also unanchored, so it tests for a substring of e.key rather than the whole key, and \. is listed twice.

Why it matters

The real problem is the fallthrough: anything not matched gets preventDefault(), and modifier combos are never exempted. Ctrl/Cmd + V, A, C, Z all report e.key as a plain letter, so they're all swallowed.

In the withdraw flow that means you cannot paste an amount, select it, copy it, or undo. Home, End and the vertical arrows are blocked too. Users copying a figure from their balance or another app have to retype it digit by digit.

The fix

An explicit handler instead of the regex:

  • return early when ctrlKey / metaKey / altKey is held, so the browser keeps its shortcuts;
  • return early for editing and navigation keys (listed by name, no accidental escapes);
  • allow a single .;
  • otherwise require the key to be exactly one digit (/^[0-9]$/, anchored).

Pasted values stay safe — onChange already runs everything through clampToDecimals, and withdrawFormSchema validates the amount on submit.


🤖 Generated with Claude Code

The onKeyDown guard on the amount field used

  /[0-9]|\.|\.|\Backspace|Tab|\Delete|ArrowLeft|ArrowRight/

which does not mean what it reads as. In a regex literal `\B` is the
non-word-boundary assertion and `\D` is "any non-digit", so the
`Backspace` and `Delete` alternatives are really `\B` + "ackspace" and
`\D` + "elete". They happen to match those two key names by accident,
but the pattern is also unanchored, so it is matching substrings of
e.key rather than the whole key.

The user-visible problem is the fallthrough: every key that is not in
that list gets preventDefault(), and modifier combos are never exempted.
Ctrl/Cmd+V, Ctrl/Cmd+A, Ctrl/Cmd+C and Ctrl/Cmd+Z all report e.key as a
plain letter, so they are all blocked. You cannot paste an amount into
the withdraw field, select it, or undo. Home, End and the vertical
arrows are blocked too.

Replace it with an explicit handler: bail out early on modifier
combos and on editing/navigation keys, allow a single '.', and otherwise
require the key to be exactly one digit. Pasted values stay safe because
onChange already runs them through clampToDecimals.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

@rajanpanth is attempting to deploy a commit to the Superteam Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@rajanpanth, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 526da52f-2140-44a4-affe-c8f13043e412

📥 Commits

Reviewing files that changed from the base of the PR and between 145486c and ef18fc3.

📒 Files selected for processing (1)
  • src/features/wallet/components/withdraw/TokenAmountInput.tsx

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.

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.

1 participant