input-mask-android icon indicating copy to clipboard operation
input-mask-android copied to clipboard

Crashes while deleting the characters

Open BenazirSh opened this issue 3 years ago • 5 comments

Hello! I have setHint as +998, when user enters numbers and deletes it, the following error is shown: Untitled

BenazirSh avatar Dec 10 '21 06:12 BenazirSh

Hey @BenazirSh

You've got to follow the bug report format when creating an issue; otherwise I'm going to close this by EOD.

taflanidi avatar Dec 10 '21 08:12 taflanidi

  • [X]

Describe the bug

The application crashes when I delete the characters set in mask

Steps to reproduce the behaviour:

  1. set mask as +998 [00] [000]-[00]-[00]
  2. Fill in the editText
  3. Delete the input including 998 and then type and number

Expected behaviour The number being typed should have appeared

Actual behaviour The application has crashed

Screenshots The screenshot from LogCat is attached above

Platform information

  • OS version: Android 11
  • Library version: 6.0
  • Device (if bug is device-specific): Samsung SM A-41

BenazirSh avatar Dec 13 '21 13:12 BenazirSh

Library version: 6.0

Let me know if version 6.1 works for you; it has this specific bug fixed.

Also, please take a look at this section of our main README, the suggestion is to add the digits property to your text field:

Still, you may use a workaround by putting the android:digits value beside your android:inputType; there, you should specify all the acceptable symbols:

<EditText
    android:inputType="number"
    android:digits="0123456789 -."
    ... />

Alternatively, if you are using a programmatic approach without XML files, you may consider configuring a KeyListener like this:

editText.setInputType(InputType.TYPE_CLASS_NUMBER);
editText.setKeyListener(DigitsKeyListener.getInstance("0123456789 -.")); // modify character set for your case, e.g. add "+()"

taflanidi avatar Dec 13 '21 14:12 taflanidi

Thanks for the reply. For some reason, after upgrading the version to 6.1 , the library does not work for me...

BenazirSh avatar Dec 14 '21 05:12 BenazirSh

Also, I noticed one behavior. Since my mask contains pre-defined numbers, 998, that is +998 [00] [000]-[00]-[00] .When I type 9 or 8 after deleting characters, it does not get displayed at once, I should press it twice. I think it has to do with my mask containing 9 and 8, because when I set my mask to +76 [00] [000]-[00]-[00], I noticed the same behaviour but with numbers 7 and 6

BenazirSh avatar Dec 14 '21 06:12 BenazirSh