devfolioco / react-otp-input

:heavy_check_mark: OTP Input Component for React
http://devfolioco.github.io/react-otp-input
MIT License
657 stars 427 forks source link

Pasting from clipboard on Android #280

Closed es1831 closed 9 months ago

es1831 commented 3 years ago

https://user-images.githubusercontent.com/8410389/114436022-de2db500-9b92-11eb-9b6a-45bf0624ebcd.mp4

AzurDrive commented 3 years ago

Hello!

Any updates on this? Cause same problems for iOS / Android auto-paste from SMS - code is not being parsed correctly and only first number is pasted.

DeadEnglish commented 3 years ago

Also running into this issue on Android, pasting from clipboard works but pasting from sms messages doesn't.

Janviba911 commented 3 years ago

I am facing same issue which was posted by @AzurDrive, Please give a solution as soon as possible @ajayns, @apollonian

AzurDrive commented 3 years ago

@DeadEnglish @Janviba911 yo guys, i can share my "hack" and overall thoughts on this library. So, you see, ths component renders 4 separate inputs, 1st input is auto-focused (default), and when you try to paste code from sms, it is pasted in this 1st input, but only 1st digit, cause maxLength is 1. Then all the rest logic - proceed inputing to other 3 inputs - doesnt work here like with pasting from clipboard. Because code got pasted directly to rendered input, not to React OTP component (somehow).

So my solution. Make on top of react-otp (place them in one container). Input should be numeric-based, maxLength 4, autofocused, controllable. color and background are transparent. also set react-otp to pointerEvents: none. Share the contolled input to react.state and pass that value to react-otp component too. all the rest styles are on yours.

LuisValgoi commented 2 years ago

@AzurDrive can you share the code?

ritikbanger commented 2 years ago

The feature is available in: https://www.npmjs.com/package/react18-input-otp

dariohirsch commented 1 year ago

Hi! any update on this issue? Im facing the same problem. Thanks!!

prateek3255 commented 1 year ago

@es1831 Can you check if this issue still exists with v3.

chocodate commented 1 year ago

It works for ios safari but such a screen appears. When I hit close it copies all the code. Could the console be forgotten somewhere?

IMG_0993

hogiyogi597 commented 10 months ago

I believe I have a fix for this in this PR here: https://github.com/devfolioco/react-otp-input/pull/428

prateek3255 commented 9 months ago

This was fixed with #428