Reputation: 11267
I have Open button
<button mat-raised-button (click)="openModal()
"type="button" color="primary">Open Modal </button>
On button button click, popup modal open and after close modal. cdk-focused
and cdk-program-focused
classes added and to this button and get some ripple effect on that.
I want to get rid of that style, want remove or overwrite those classes those added to button after close modal*
Upvotes: 4
Views: 5229
Reputation: 354
I faced same problem with Angular 11 and inside mat-drawer for the first link it was adding this effect. This span was being added inside first link whenever I open the mat-drawer
<span class="mat-button-focus-overlay"></span>
So I had to do this in my component's scss
::ng-deep .mat-button-focus-overlay {
background-color: transparent !important;
}
This may be similar to above answers, hope this will help someone working with mat-drawer.
Upvotes: 0
Reputation: 39
Even I went through lots of trial and error method,but finally got fixed with it by adding following feature while creating model.
in the diolog creation add this
restoreFocus:false
*Whether the dialog should restore focus to the *previously-focused element, after it's closed.
Upvotes: 0
Reputation: 28708
I suggest two solutions:
1. First, set an additional class on that button in order to avoid that all the mat-raised-buttons be affected by the style change, it's not your aim, I suppose.
HTML:
<button mat-raised-button class="myButton" (click)="openDialog();">Pick one</button>
CSS:
.myButton:focus{
box-shadow: 0 0 rgba(255, 255, 255, 1) !important;
transition:none !important;
background-color: rgba(255, 255, 255, 1) !important;
-webkit-tap-highlight-color:rgba(255, 255, 255, 1) !important;
}
Then you can set the style of mat-raised-button either by
a) setting it in component's stylesheet with ::ng-deep:
::ng-deep .myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
::ng-deep .mat-app-background{
background: white !important
}
b) setting with ViewEncapsulation.none:
Class:
import { ViewEncapsulation } from '@angular/core';
...
@Component({
...
encapsulation:ViewEncapsulation.None
})
CSS:
.myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
.myButton>.mat-app-background{
background: white !important
}
c) setting it in style.css:
.myButton>.mat-button-focus-overlay {
background-color:transparent !important;
}
.myButton>.mat-app-background{
background: white !important
}
...
<input matInput #input [(ngModel)]="name" placeholder="What's your name?">
...
<button mat-raised-button class="myButton" (click)=" input.focus();openDialog() ">Pick one </button>
Upvotes: 5
Reputation: 11267
.mat-button-focus-overlay {
background-color:transparent !important;
}
.mat-app-background{
background: transparent !important
}
Upvotes: 3