question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cursor jumps to position 0 on click or select if mask is null or undefined

See original GitHub issue

So, 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ColinMorris83commented, Apr 7, 2020

Have added it into https://github.com/JsDaddy/ngx-mask/pull/708 - the directive shouldn’t try and do anything now on empty masks

2reactions
ColinMorris83commented, Apr 7, 2020

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found