fix(wallet): repair the withdraw amount key filter (paste is currently blocked) - #1479
fix(wallet): repair the withdraw amount key filter (paste is currently blocked)#1479rajanpanth wants to merge 1 commit into
Conversation
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>
|
@rajanpanth is attempting to deploy a commit to the Superteam Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
The bug
TokenAmountInputfilters keystrokes on the withdraw amount field with:This doesn't mean what it reads as. In a regex literal
\Bis the non-word-boundary assertion and\Dis "any non-digit", so the two alternatives compile to\B+ackspaceand\D+elete. They match those key names by accident. The pattern is also unanchored, so it tests for a substring ofe.keyrather 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,Zall reporte.keyas 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,Endand 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:
ctrlKey/metaKey/altKeyis held, so the browser keeps its shortcuts;.;/^[0-9]$/, anchored).Pasted values stay safe —
onChangealready runs everything throughclampToDecimals, andwithdrawFormSchemavalidates the amount on submit.🤖 Generated with Claude Code