Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

Cursor moves to start when there is a 0 in the decimal, How to stop this behavior?

Open iHamzaKhanzada opened this issue 2 years ago • 2 comments

  • OS: Windows
  • Browser: Microsoft Edge
  • Inputmask version: 5.0.9-beta.62

I first made sure I am using the latest and greatest version of inputmask (without obviously the jquery-inputmask as it has been deprecated), the version is 5.0.9-beta.62. I downloaded this release from the Github, opened the index.html page which has 3 textboxes, date, currency and email. My concern is purely with currency, here is the HTML of the demo I am testing

image

so here are the steps to reproduce:

Working scenario: Type $ 0.51 in the currency textbox, leave the textbox and then click again on the textbox on the right most decimal part (1 in this case), the cursor stays where we have clicked, (Screenshot attached for reference)

image

Now the other case: Type $ 0.50 in the currency textbox, leave the textbox and then click again on the textbox on the right most decimal part (0 in this case), the cursor pushes back to start, this should not happen (I want to disable this behavior of cursor moving) (screenshot attached)

image

Another scenario: Type $0.05 in the currency textbox and leave the textbox and then click again on the textbox pointing the cursor before the 5 decimal part, the cursor moves back to start, unwanted behavior, screenshot attached

image

iHamzaKhanzada avatar Apr 03 '24 07:04 iHamzaKhanzada

I was able to reproduce the same behavior. I think this might be a bug. The reason is you have the option positionCaretOnClick set to the default value of radixFocus. So as I understand, the examples with 0.50 and 0.05 work correctly and the example with 0.51 doesn't.

There is a workaround for this - set positionCaretOnClick to none like this: <input-mask alias="currency" prefix="$ " positionCaretOnClick="none"></input-mask>

Techn1c4l avatar Apr 04 '24 10:04 Techn1c4l

Thanks, using positionCaretOnClick fixed the issue.

iHamzaKhanzada avatar Apr 05 '24 13:04 iHamzaKhanzada

@iHamzaKhanzada , @Techn1c4l ,

Version 5.0.9-beta.68 updated the radixFocus to more desirable behavior.

RobinHerbots avatar May 06 '24 09:05 RobinHerbots