CaioQuirinoMedeiros / react-native-currency-input

A simple currency input component for both iOS and Android
https://www.npmjs.com/package/react-native-currency-input
MIT License
158 stars 25 forks source link

Issues editing/deleting input when you leave and re-focus onto the CurrencyInput when using suffix #23

Open mmfire118 opened 2 years ago

mmfire118 commented 2 years ago

When you enter text into the CurrencyInput, close the keyboard, and re-focus onto the input, the cursor moves to the end, behind the suffix.

As a result when you try to delete or edit the value, the cursor moves directly after the first character of the input.

This causes unexpected behavior which is annoying for the user.

https://user-images.githubusercontent.com/30126023/160305378-3cd2b5c1-a433-470d-ac92-b348160f0bf8.mp4

It would be great if the cursor moved directly before the suffix if the CurrencyInput was not empty when you re-focus onto it.

mmfire118 commented 2 years ago
import CurrencyInput from 'react-native-currency-input';

const [value, setValue] = React.useState(null)

<CurrencyInput
        value={value}
        onChangeValue={setValue}
        prefix=""
        delimiter=","
        separator="."
        precision={1}
        minValue={0}
        maxValue={99.9}
        suffix="%"
/>
CaioQuirinoMedeiros commented 2 years ago

I'll take a look into it!

mmfire118 commented 2 years ago

Any updates?