retyui / react-native-confirmation-code-field

A react-native confirmation code field compatible with iOS, Android and Web
MIT License
1.07k stars 125 forks source link

removed maxLength to allow pasting longer text than field #222

Closed rajpootathar closed 1 year ago

rajpootathar commented 1 year ago

reason behind doing it is when copying from SMS, you are can copy full sms and it would not paste.. by doing so you can paste whole length and then when using it you can do something like this

const onChange = useCallback((text: string) => { text = text.replace(/\D/g, '').slice(0, 6) setCode(text) }, [])

retyui commented 1 year ago

if you need to unset maxLength just pass empty value

<CodeField
  maxLength={undefined}
/>
rajpootathar commented 1 year ago

Actually i need 6 digits But i need to be able to copy paste whole sms and then only take 6 digits from sms or however many digits are there in maxlength.

On Fri, 16 Jun 2023 at 6:23 PM Davyd NRB @.***> wrote:

if you need to unset maxLength just pass empty value

<CodeField maxLength={undefined}/>

— Reply to this email directly, view it on GitHub https://github.com/retyui/react-native-confirmation-code-field/pull/222#issuecomment-1594670513, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ3O3WD2MMXIT7DJ4VNE6TXLRM3VANCNFSM6AAAAAAZJDU2NY . You are receiving this because you authored the thread.Message ID: @.*** com>

retyui commented 1 year ago

teen use a combination of maxLength & onChangeText

<CodeField
  maxLength={undefined}
  onChangeText={text => setValue( text.replace(/\D/g, '').slice(0, 6) )}
/>
rajpootathar commented 1 year ago

I did but it does not paste more then maxlength

On Fri, 16 Jun 2023 at 7:58 PM Davyd NRB @.***> wrote:

teen use a combination of maxLength & onChangeText

<CodeField maxLength={undefined} onChangeText={text => setValue( text.replace(/\D/g, '').slice(0, 6) )}/>

— Reply to this email directly, view it on GitHub https://github.com/retyui/react-native-confirmation-code-field/pull/222#issuecomment-1594833112, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ3O3X4EQDRB3H62UJETRLXLRYC5ANCNFSM6AAAAAAZJDU2NY . You are receiving this because you authored the thread.Message ID: @.*** com>

retyui commented 1 year ago

can you try maxLength={99999} ?

rajpootathar commented 1 year ago

Then it will generate 99999 blocks I need 6 blocks and able to copy long text “your otp for x application is 662244”

On Fri, 16 Jun 2023 at 8:04 PM Davyd NRB @.***> wrote:

can you try maxLength={99999} ?

— Reply to this email directly, view it on GitHub https://github.com/retyui/react-native-confirmation-code-field/pull/222#issuecomment-1594840989, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ3O3WY46VR2FFPYD6U6LTXLRYWPANCNFSM6AAAAAAZJDU2NY . You are receiving this because you authored the thread.Message ID: @.*** com>

retyui commented 1 year ago

Prove it!

as I know the cellCount: number prop is responsible for blocks count

111

rajpootathar commented 1 year ago

Let me check again

On Fri, 16 Jun 2023 at 8:08 PM Davyd NRB @.***> wrote:

Prove it!

as I know the cellCount: number prop is responsible for blocks count

[image: 111] https://user-images.githubusercontent.com/4661784/246456222-ef82494b-4ede-4ccd-94e4-46d1bd54128c.png

— Reply to this email directly, view it on GitHub https://github.com/retyui/react-native-confirmation-code-field/pull/222#issuecomment-1594846894, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ3O3UTH7NG2GLI72LMDIDXLRZHNANCNFSM6AAAAAAZJDU2NY . You are receiving this because you authored the thread.Message ID: @.*** com>

rajpootathar commented 1 year ago

thanks that solved the problem.. the prop should be sent after cellCount

On Fri, Jun 16, 2023 at 8:10 PM Athar Rajpoot @.***> wrote:

Let me check again

On Fri, 16 Jun 2023 at 8:08 PM Davyd NRB @.***> wrote:

Prove it!

as I know the cellCount: number prop is responsible for blocks count

[image: 111] https://user-images.githubusercontent.com/4661784/246456222-ef82494b-4ede-4ccd-94e4-46d1bd54128c.png

— Reply to this email directly, view it on GitHub https://github.com/retyui/react-native-confirmation-code-field/pull/222#issuecomment-1594846894, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ3O3UTH7NG2GLI72LMDIDXLRZHNANCNFSM6AAAAAAZJDU2NY . You are receiving this because you authored the thread.Message ID: @.*** com>