Issue
I am trying to programatically set focus on an Angular Material checkbox, but it is not working on angular 12 app.
Here is what I have tried.
I created a temp reference like this,
@ViewChild('maaz') chk:any;
and on a button click, I call this method:
this.chk.focus();
Here is the angular 6 application on stackblitz where focus works as reference how it should have worked.
Here is my code on stackblitz
Solution
There is a bug in Angular latest version as Vega mentioned,
Material checkbox focus issue - https://github.com/angular/components/issues/18912
The workaround is to add the below style,
.mat-checkbox-persistent-ripple {
.mat-checkbox.cdk-focused & { opacity: 0.12; }
}
Answered By - anonymous
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.