-
Notifications
You must be signed in to change notification settings - Fork 11
fix: iOS paste not working #7
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
|
@magrinj, thank you for submitting the fix! Do you think we can find a way to test this past feature? |
|
@yjose With unit testing I don't think so, as the issue is actually that we can't have the tooltip when doing a long-press to paste on the otp-input on iOS. This can only be done by doing E2E test otherwise. |
|
ok sure noted, will check the PR tonight and retest it and add my review 🙏 |
|
No problem, thanks for your reactivity ! |
|
I've noticed something about how OTP codes work while pasting a long text. Let's say you receive a message like "Your OTP code is 234323." If you copy that entire message and then try to paste it, it won't work correctly with the current setup. This is because we are passing the To fix this, I believe we should remove the |
|
Pretty good catch, I just try to directly copy an OTP code instead of the whole message. |
|
yeah sure take your time |
|
@yjose Ok, I've fixed the issue you had. |
|
I don't believe it's necessary to include I think you can keep the Also few tests that should be fixed, and i suggest to only delete the checks related to |
|
I can remove the |
|
I see your point. How about we try this approach instead? const defaultPasteTransformer = (maxLength: number) => (pasted: string) => {
// match exactly maxLength digits, not preceded or followed by another digit
const otpRegex = new RegExp(`(?<!\\d)(\\d{${maxLength}})(?!\\d)`);
const match = pasted.match(otpRegex);
return match?.[1] ?? '';
};then pasteTransformer: props.pasteTransformer ?? defaultPasteTransformer(props.maxLength),This approach means you won't need to update either the user-input implementation or the props types. |
|
Ok everything is fixed 🙂 |
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.
Sounds good, thank you @magrinj for your efforts
This PR is fixing the following issues:
pasteis not possible on iOS because the opacity is set to 0 (the workaround is to set the opacity to 0.02, the color to transparent and hide the caret)pasteTransformerwas not passed touseInputfrom the propsdefaultPasteTransformerremoving non numeric character by defaultstyleof the input, merge them