-
Notifications
You must be signed in to change notification settings - Fork 419
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
allowDecimalSeparators does't always work correctly when paste a number into the input #349
Comments
i have same issue |
Hi. Same issue here...:/ |
Hi, @s-yadav |
@tenkij thank for your code-pen i had fixed the issue. Love you 3000 |
Hi @s-yadav, |
I'm not very sure but i think maybe it's forcing formatting the value since it's a number greater than a thousand. By default if thousandSeparator prop it's not present it shouldn't force formatting, but it's a posibility. |
Still relevant today. Any idea how to fix it? Maybe i'll be able to provide a PR, but i need some guidance |
@Toumash That would be great! Let me know how I can help you with this! Thanks! |
@nikhil-varma You can review the attached PR :) |
For those who are waiting for the PR to be merged: you can use this customInput hack const DemoField = useMemo(() => NumberFormatCommaPasteHackTextField(setValue), []);
// HACK: replace with normal TextField after this PR is merged https://github.com/s-yadav/react-number-format/pull/556
const NumberFormatCommaPasteHackTextField = (setValue) =>
(props) => {
return <TextField
{...props}
onPaste={(e) => {
let pastedText = e.clipboardData.getData('text');
if (pastedText.indexOf(',') !== -1) {
e.preventDefault();
setValue(pastedText.replace(',', '.'));
}
}}
/>
}
return <NumberFormat
customInput={DemoField}
allowedDecimalSeparators={[",", "."]}
decimalSeparator={'.'}
thousandSeparator=" "
/> |
allowedDecimalSeparators={[",", "."]}
decimalSeparator='.'
decimalSeparator=','
https://codesandbox.io/s/react-number-format-demo-f7245
The text was updated successfully, but these errors were encountered: