react-otp-input icon indicating copy to clipboard operation
react-otp-input copied to clipboard

Pasting from clipboard on Android

Open es1831 opened this issue 4 years ago • 6 comments

  • Describe the Feature Request Having an issue pasting a code from clipboard on android

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

  • Describe Preferred Solution should behave the same as pasting, where the numbers are auto-filled once you click on the number

es1831 avatar Apr 12 '21 17:04 es1831

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.

AzurDrive avatar May 06 '21 14:05 AzurDrive

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

DeadEnglish avatar May 19 '21 10:05 DeadEnglish

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

Janviba911 avatar May 20 '21 06:05 Janviba911

@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.

AzurDrive avatar May 20 '21 08:05 AzurDrive

@AzurDrive can you share the code?

LuisValgoi avatar Dec 20 '21 16:12 LuisValgoi

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

ritikbanger avatar Aug 09 '22 17:08 ritikbanger

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

dariohirsch avatar Nov 24 '22 14:11 dariohirsch

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

prateek3255 avatar Mar 25 '23 15:03 prateek3255

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

chocodate avatar Mar 31 '23 11:03 chocodate

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

hogiyogi avatar Nov 09 '23 17:11 hogiyogi

This was fixed with #428

prateek3255 avatar Dec 12 '23 05:12 prateek3255