Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Cursor moves to the one before last position after mouse select all and enter new character #243

Open
vvnc opened this issue Oct 16, 2018 · 0 comments

Comments

@vvnc
Copy link

vvnc commented Oct 16, 2018

Bug

Steps to reproduce:

  1. Go to the official demo page: https://htmlpreview.github.io/?https://github.com/angular-ui/ui-mask/master/demo/index.html
  2. Select some mask e.g. (999) 999-9999
  3. Enter any characters in the "Masked input" field
  4. Put the mouse cursor at the end
  5. Select half of characters with the left mouse key not leaving the input
  6. Continue selection with the left mouse key outside of input
  7. Enter any characters

Result: cursor is on the one before last position

Expected behaviour: cursor is on the last position

Demo:
ui-mask-cursor-bug

Reason

The selection lenght is recorded on mouseout event. When mouse leaves the input and selection is not finished yet, the selection is not recorded anymore. The wrong selection length corrupts the cursor position which leads to the error.

Suggested fix

Record the cursor position on keydown event too.

vvnc added a commit to vvnc/ui-mask that referenced this issue Oct 16, 2018
@vvnc vvnc changed the title Cursor moves to the second character after mouse select all and enter new character Cursor moves to the one before last position after mouse select all and enter new character Oct 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant