imaskjs icon indicating copy to clipboard operation
imaskjs copied to clipboard

What exactly is overwrite mode?

Open cgatian opened this issue 5 years ago • 1 comments

From the docs

It enables characters overwriting instead of inserting

What exactly does that mean? From my testing enabling or disabling overwrite has no affect on the output produced. The only unit test produces the same result regardless of overwrite being true or false.

https://stackblitz.com/edit/imask-overwrite?file=index.js

cgatian avatar Nov 13 '20 14:11 cgatian

I also had the same doubt, but I identified the issue 129 that originated this functionality and I understood the problem it solves.

Explaining: The overwrite property is useful when you work with an input and, after typing a value, you go back to some previous position and type again. At that point, it will check the overwrite. If it has 'true' then it replaces the character that is currently in it. If it has 'false' then it adds a new character and pushes the others.

Simulate: https://stackblitz.com/edit/js-1rivqr?file=index.js

overwrite 'true':

  1. Fill the input with 12345;
  2. Go back to second position and type 7;
  3. The result will be: 17345;

overwrite 'false':

  1. Fill the input with 12345;
  2. Go back to second position and type 7;
  3. The result will be: 127345;

In unit test this functionality is not clear, as it needs an input to simulate.

otacilioMota avatar Dec 16 '21 21:12 otacilioMota