Skip to content

specialCharacters needs to be nullable and work with dropSpecialCharacters #1512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Et3rnal opened this issue Mar 4, 2025 · 1 comment

Comments

@Et3rnal
Copy link

Et3rnal commented Mar 4, 2025

🐞 bug report

specialCharacters needs to be nullable and work based on dropSpecialCharacters

Description

I use ngx-formly so I have a custom component which wrappers ngx-mask so I can use it in my ngx-formly forms. I noticed that I can't make specialCharacters attribute optional if I provide it with null or empty array it will block special Characters even when dropSpecialCharacters is set to false!!!

I tried to do [attr.specialCharacters] but that breaks the mask as well

the only way is to remove the specialCharacters all together!

The goal of using ngx-fromly to make reusable form components, so I need all of the ngx mask attributes to be available added to the HTML but only apply what id defined from the ts file

🔬 Minimal Reproduction

Let me know if you need this, there isn't any errors thats all you need

        <input
            [dropSpecialCharacters]="false"
            [specialCharacters]="[]"
            mask="A*@A*.A*"
        />

The @ is getting droped
This shouldn't happen as dropSpecialCharacters is false, also since I must have specialCharacters if you allow it to be null and ignore all special characters or maybe give an option to include all like * if null not an option

or simply fix [attr.specialCharacters]=""

🔥 Exception or Error

None

🌍 Your Environment

Angular Version:
17.3.10


"ngx-mask": "^19.0.6",

Thanks

@asollberger
Copy link

I had a similar issue with ngx-mask (used patterns and dropSpecialCharacters, specialCharacters was undefined) and when trying to delete a character it failed here:

const specialCharacters = this.specialCharacters().length

const specialCharacters = this.specialCharacters().length ? this.specialCharacters() : this._config.specialCharacters;

I found a workaround for this issue by defaulting the specialCharacters to initialConfig.specialCharacters:

this.specialCharacters = options.specialCharacters ?? [...initialConfig.specialCharacters];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants