Ngx-mask: Handle undefined or null mask

Created on 15 Apr 2019  路  2Comments  路  Source: JsDaddy/ngx-mask

Hello,

I have a generic component that add validators, embed errors notifications, set mask, and do other stuffs about just an input component.

Specifically, my component get the input type and mask through the @Input variables.
In the case I provide an input type="number", and do not specify a mask (which is then null/undefined), I get the following javascript error:

DOMException: Failed to set the 'selectionStart' property on 'HTMLInputElement': The input element's type ('number') does not support selection.
at MaskDirective.push../node_modules/ngx-mask/fesm5/ngx-mask.js.MaskDirective.onFocus (http://localhost:4200/modules-screens-screens-module.js:2480:31)

Is it possible to totally deactivate the mask when its content is null or undefined?

Thanks!

Most helpful comment

Ok, I understand It does not provide many benefits on number input types (though...).
But it still seems strange to me that the directive effectively do something when no mask is provided...
Could be great if no error could be generated in this case.

All 2 comments

@asterius321 Hello, frist of all mask work only with input type text

Ok, I understand It does not provide many benefits on number input types (though...).
But it still seems strange to me that the directive effectively do something when no mask is provided...
Could be great if no error could be generated in this case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

humpedli picture humpedli  路  3Comments

cabbott65 picture cabbott65  路  4Comments

raisiqueira picture raisiqueira  路  3Comments

mnagaev picture mnagaev  路  3Comments

Et3rnal picture Et3rnal  路  4Comments