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

Bug when replacing through selection #2 #566

Open
TiTUS-web opened this issue Nov 30, 2022 · 0 comments
Open

Bug when replacing through selection #2 #566

TiTUS-web opened this issue Nov 30, 2022 · 0 comments

Comments

@TiTUS-web
Copy link

TiTUS-web commented Nov 30, 2022

Versions of V-Mask and Vue

2.2.4, 2.6.11

Reproduction Link

https://codesandbox.io/embed/v-mask-bug-fnm7m3?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

  1. Make sure '$##A' is used in the mask;
  2. Enter the numbers in the input box, for example, '123A'.
  3. Select 3 with the mouse selection and enter e.g. 'A', you should get '12AA'.
  4. Then delete the first letter A;
  5. Determine the error, now the entered value '12A' does not match the mask;

What is Expected?

The value entered, instead of 3, was expected not to be displayed when entered.

What is actually happening?

The entered value is not masked in any way.

Why can this happen ?

The v-mask sources have an updateValue() method in which we get the entered value and check it to change it later. There are 3 conditions in the check: isValueChanged, isLengthIncreased and isUpdateNeeded, which is a resultant check of the previous conditions.

The whole problem is the condition isLengthIncreased, when we enter a value, it checks that if the length of the current value is greater than the length of the previous value, then the condition is true, otherwise it is false. And if the value is false, then the condition isUpdateNeeded, which checks all conditions for true, also fails and is false, and the value does not change in any way.

This problem is solved by removing the condition isLengthIncreased !

image-1
image-2

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