-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(InputMask): Paste at Cursor Selection #5286
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>. |
thanks @Triggs125 looks good to me but assigned to PrimeTek for testing before merging. |
Thank you for addressing this and your contribution. I just took quick view to your code. I will be reviewing and testing it more detailed asap. |
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.
Hey @Triggs125 I reviewed your contribution it looks good but I think we can add one extra parameter to handleInputChange function to prevent code duplication. I have tried this version and it seems working properly. What do you say??
const handleInputChange = (e, isOnPaste = false) => {
if (props.readOnly) {
return;
}
if (!isOnPaste) {
let pos = checkVal(true);
caret(pos);
}
updateModel(e);
if (props.onComplete && isCompleted()) {
props.onComplete({
originalEvent: e,
value: getValue()
});
}
};
onPaste={(e) => handleInputChange(e, true)}
I agree with @nitrogenous |
Run |
The input mask component currently pastes contents at the first empty value position instead of the cursor selection. Providing an undefined position to the caret function *mostly* fixes this issue because after the paste happens, the cursor is returned to the last empty value position instead of at the end of the newly pasted value.
The input mask component currently pastes contents at the first empty value position instead of the cursor selection. Providing an undefined position to the caret function mostly fixes this issue because after the paste happens, the cursor is returned to the last empty value position instead of at the end of the newly pasted value.
Defect Fixes
Fix #5285