Cursor jumps to position 0 on click or select if mask is null or undefined
See original GitHub issueSo, I have a custom input component. My way to deal with multiple ControlValueAccessors was to put [mask] directly to the input element and connect it with a @Input() component property like this:
<ms-input fromControlName="somecontrol" [mask_]="000-000"></ms-input>
Then in input.component.ts i have @Input() mask_: string and it’s binded to [mask] directive on the input element.
And before ngx-mask@8.2.0 it worked fine, but now If my mask_ is not provided, something breaks. With no errors cursos on the input keeps jumping to position 0 if I click somewhere in the input or try to select part of it’s value.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React controlled input cursor jumps - Stack Overflow
If your value is controlled by state, React will maintain the input's cursor position. The problem is when the input receives a change...
Read more >Cursor position when input mask is set [RESOLVED] - Get Help
When I click into a field with a standard or custom mask applied, the cursor jumps to the position I've clicked. Or to...
Read more >Changelog - Cypress Documentation
Cypress now throws an error if any Cypress commands are invoked from inside a .should() callback. This previously resulted in unusual and undefined...
Read more >DxTextBox - Set cursor position to start if mask is defined
I am now creating a directive, but the caret seems to jump back to position where it was selected.
Read more >JavaScript and jQuery by Examples
The attribute required specifies that input cannot be empty. The attribute autofocus sets the focus to this element. <input type="text" id="txtZipcode" name=" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Have added it into https://github.com/JsDaddy/ngx-mask/pull/708 - the directive shouldn’t try and do anything now on empty masks
@vmehrjouei I can take a look at this as have done the same thing myself with a separate input that doesn’t have the mask directive if don’t need a mask. Basically it would essentially be a check in all of the directive methods to just return and do nothing if the mask is empty, does that seem ok? I don’t think this will fix the input type of number issue though as I presume you’d want to have a mask still for that case?