'Angular Material: How close overlay's backdrop also on right click?
Solution 1:[1]
Right click has a default action which takes function by the browser itself.
I recommend not to override that functionality. Just add a listener for contextmenu
event:
document.getElementByTagName('body')[0]
.addEventListener('contextmenu', (ev) => {
this.matMenu.closeMenu();
}, false);
Solution 2:[2]
Another method
Open the matdialog :
this.dialogRef = this.dialog.open(template);
Listen contextmenu action :
<div (contextmenu)="closeDialog($event)"></div>
Close method :
closeDialog(event) {
this.dialogRef.close();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mahdi Zarei |
Solution 2 | Piva Gregory |