ngx-mask icon indicating copy to clipboard operation
ngx-mask copied to clipboard

NgxMask doesn't work with matAutocomplete

Open anmal opened this issue 4 years ago • 5 comments

I'm trying to use NgxMask along with matAutocomplete. They don't work together. I get an error:

Error: More than one custom value accessor matches form control with unspecified name attribute

Please, make them compatible or add your own autocomplete feature to NgxMask.

Thank you in advance!

anmal avatar Nov 10 '20 10:11 anmal

I confirm that doesn't work, same error:

<div [formGroup]="formGroup">
  <mat-form-field style="width: 100%; margin-top: 5px">
    <input matInput
           [matDatepicker]="picker"
           autocomplete="off"
           placeholder="gg/mm/aaaa"
           formControlName="dateControl"
           mask="d0/M0/0000"
           [leadZeroDateTime]="true"
           (ngModelChange)="onDateChanged($event)"
           style="width: 100%">
    <mat-datepicker-toggle matSuffix [for]="picker" tabindex="-1">
      <mat-icon matDatepickerToggleIcon>expand_more</mat-icon>
    </mat-datepicker-toggle>
    <mat-datepicker #picker></mat-datepicker>
  </mat-form-field>
</div>

stefanofalasca avatar Nov 18 '20 09:11 stefanofalasca

Hello everyone. I also face that issue with matAutocomplete, any thoughts on this? @NepipenkoIgor @anmal

aintnomoreloyalty avatar Apr 29 '21 12:04 aintnomoreloyalty

Hello everyone. I also face that issue with matAutocomplete, any thoughts on this? @NepipenkoIgor @anmal

As I understood, the only way is to extend ngx-mask functionality with its own autocomplete implementation, but you can't use matAutocomplete along with ngx-mask because they both are custom form controls with their own ValueAccessor. But angular allows you to use only one ValueAccessor. You can either implement your own autocomplete for ngx-mask form controls, or your own mask for matAutocomplete form controls (that was our way).

anmal avatar Apr 29 '21 15:04 anmal

Hello everyone. I also face that issue with matAutocomplete, any thoughts on this? @NepipenkoIgor @anmal

As I understood, the only way is to extend ngx-mask functionality with its own autocomplete implementation, but you can't use matAutocomplete along with ngx-mask because they both are custom form controls with their own ValueAccessor. But angular allows you to use only one ValueAccessor. You can either implement your own autocomplete for ngx-mask form controls, or your own mask for matAutocomplete form controls (that was our way).

I had the same problem: I needed to mask a MatAutocomplete.

Similar to what anmal did we "hacked" a vanilla-text-mask to the MatAutocomplete input. Our only problem with vanilla-text-mask was that it has no type definitions.

Res42 avatar May 07 '21 14:05 Res42

Hello. I have this problem with matAutocomplete too. Do you have any news? Or any idea where the root cause is coming from? From ngx-mask or from Angular Material?

lidiagabriela avatar Aug 22 '23 09:08 lidiagabriela