catamphetamine / react-phone-number-input

React component for international phone number input
http://catamphetamine.gitlab.io/react-phone-number-input/
MIT License
915 stars 193 forks source link

Android Chrome: PhoneInput with maxLength and smartCaret has weird cursor side effects #434

Open jonathan-villanueva opened 9 months ago

jonathan-villanueva commented 9 months ago

When entering more than the max amount of digits on Android Chrome the cursor will move back and be positioned strangely.

https://github.com/catamphetamine/react-phone-number-input/assets/34611132/f5be2258-7e69-4375-8d29-35f95865fd67

catamphetamine commented 9 months ago

Post your code.

P.S. I dunno what might be the case in your case, so there won't be a solution in this thread.

jonathan-villanueva commented 9 months ago
                        <PhoneInput
                            data-testid="PhoneInputInput"
                            country="US"
                            value={value || undefined}
                            onChange={onChange}
                            type="tel"
                            defaultCountry="US"
                            autoFocus={true}
                            limitMaxLength={true}
                        />
    const onChange = (value: string) => {
        setFormData({ ...formData, phone_number: value })
    }
catamphetamine commented 9 months ago

I see, so the bug only manifests when limitMaxLength property is used.

I saw weird caret behavior on Android in the past years. Usually it happens in unconventional browsers that don't handle dynamic caret positioning properly. In the older years, that was Samsung Browser, for example.

I'd mark this one as "won't fix".