-
Notifications
You must be signed in to change notification settings - Fork 5
fix: enhance keyboard input handling for CustomNumberInput component #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughReworked numeric input handling: Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant CustomInput as CustomNumberInput
participant TransferModal as TransferModal
User->>Browser: Type key or paste clipboard
Browser->>CustomInput: deliver key event / paste data
CustomInput->>CustomInput: detect comma/dot, normalize separators, strip thousands, sanitize value
alt valid cleaned value
CustomInput->>TransferModal: onChange(cleanedValue)
TransferModal->>TransferModal: format integer with thousands, preserve decimal/trailing dot
TransferModal->>CustomInput: set formatted display value
else invalid
CustomInput->>CustomInput: block/ignore input
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@platforms/eCurrency/client/src/components/ui/custom-number-input.tsx`:
- Around line 28-43: The paste handler handlePaste currently blindly replaces
all commas with dots which corrupts numbers using thousands separators; update
handlePaste to detect the decimal separator by checking the last occurrence of
'.' and ',' in pastedText (whichever appears later is the decimal separator),
then remove all occurrences of the other separator (treat as thousands
separators), normalize the detected decimal separator to a dot, strip any
non-digits or the single decimal point, and ensure only one decimal point
remains before calling onChange with the sanitized value; reference handlePaste,
pastedText, cleaned, parts, and sanitized to locate and adjust the logic.
…international formats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@platforms/eCurrency/client/src/components/ui/custom-number-input.tsx`:
- Around line 15-25: The handling currently only replaces a trailing comma;
update the logic that uses nativeEvent.data to convert a user-inserted comma at
the caret into a dot anywhere in the string: when nativeEvent.data === ','
determine the insertion index from the input's caret (using
selectionStart/selectionEnd from the event target), replace the comma at that
index in value with '.' (instead of only replacing a trailing comma), then
proceed to strip formatting commas into cleanValue; reference nativeEvent.data,
value, cleanValue and use the event target's selectionStart/selectionEnd to
locate the inserted comma.
platforms/eCurrency/client/src/components/ui/custom-number-input.tsx
Outdated
Show resolved
Hide resolved
…etter decimal handling
Description of change
transfer-modal.tsx
custom-number-input.tsx
Issue Number
Closes #710
Type of change
How the change has been tested
Tested on desktop + virtual device.
Couldn't test on iOS, but it should work
Change checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.