react-intl-tel-input icon indicating copy to clipboard operation
react-intl-tel-input copied to clipboard

Fixes #260: Fix cursor position

Open tomegz opened this issue 6 years ago • 11 comments

tomegz avatar Jan 08 '19 12:01 tomegz

Coverage Status

Coverage increased (+0.02%) to 94.048% when pulling df9c35da4de45e156d7f5081f03360af299c7089 on tomegz:improved-6.1.0 into 6c8ce61a1b0239aaf9fa9bf24320eff59111f108 on patw0929:master.

coveralls avatar Jan 08 '19 12:01 coveralls

Can you close this?

I fixed this issue some time back, will have a look & fix it

But I dont see this happening in our live demo app

superhit0 avatar Jan 08 '19 13:01 superhit0

Look at the code from my example #260 . I'm using number instead of value. If you want to reproduce it on master just change :

this.setState({
  [name]: value,
})

to:

this.setState({
  [name]: number,
})

in example.js. Then run npm start and see that example brakes.

tomegz avatar Jan 08 '19 14:01 tomegz

can you tell why are you using number?

Why can't you use value?

like in example

I am just trying to understand the use case. like why would you format a number which has not been completely entered

superhit0 avatar Jan 08 '19 14:01 superhit0

My use case is, that I want to show the user the formatted number including the country code. I think the cursor shouldn't brake regardless of what I want to in the input.

tomegz avatar Jan 08 '19 14:01 tomegz

ok got your use case.

But I think we need to improve our logic here.

Just try this with your change

  • Completely enter the formatted number
  • After that move the cursor to middle, then delete 1 number by clicking backspace
  • the cursor will jump to end

@tomegz would you like to help us on this?

This might help https://github.com/patw0929/react-intl-tel-input/blob/master/src/components/IntlTelInputApp.js#L1180

superhit0 avatar Jan 08 '19 14:01 superhit0

@superhit0 You're right, I didn't take it into account. Yes, I'll see what I can do when I have some time 👍

tomegz avatar Jan 08 '19 15:01 tomegz

This might help as well https://github.com/patw0929/react-intl-tel-input/pull/221/files

superhit0 avatar Jan 08 '19 15:01 superhit0

putting a do not merge for now

superhit0 avatar Jan 08 '19 16:01 superhit0

@tomegz I have raised another PR, can you can test your use cases on those changes?

https://github.com/patw0929/react-intl-tel-input/pull/262

superhit0 avatar Jan 09 '19 01:01 superhit0

I still have an issue with the curser when I enter any number starting with +2784... the curser will then move to the front of the cell phone number.

Lucas015 avatar Apr 16 '21 15:04 Lucas015