Angular Material – 将 matsnackbar 置于所有对话框之上

huangapple go评论88阅读模式
英文:

Angular Material -make the matsnackbar above all dialogs

问题

我有一个警告mat-snackbar,还有一个对话框。
我的问题是对话框出现在mat-snackbar上方并将其隐藏。
因为包装div使用相同的material类,而material使最后一个对话框位于其他对话框之上。

要使用“panelClass”不起作用
将全局CSS应用于包装类
将第一个类子元素的z-index设置得更高(这不好,因为有时它将成为第二个)

英文:

I have a Warning mat-snackbar And I have a dialog.
my problem is that the dialog appears above the mat-snackbar and hides it.
Because the wrapping div uses the same material class And material make the last dialog above the others

To use "panelClass" its not helping
Apply global css to the wrapper class
Make the first class child with a Higher z-index (it's not good - because some times it will be second)

答案1

得分: 3

There is no way to control the order of Angular's cdk-overlay containers.
Also, there is no way to add a custom class to the overlay itself, but to its child only - which is not helpful in your case, since you want to increase the z-index value of the parent. The parent is also not controllable via the panelClass property supplied by Angular-Material.

The only solution I can see in this case is, to display the snack bar later in time after displaying the dialog.
If you already displayed the snack-bar and then opened the dialog, I recommend you in this case to dismiss the snack-bar and re-show it. In this way you'll make sure that the snack bar is logically always the latest overlay, and will be displayed above all other overlay containers.

英文:

There is no way to control the order of Angular's cdk-overlay containers.
Also, there is no way to add a custom class to the overlay itself, but to its child only - which is not helpfull in your case, since you want to increase the z-index value of the paren. The parent is also not controlable via the panelClass property supplied by Angular-Material.

The only solution I can see in this case is, to display the snack bar later in time after displaying the dialog.
If you already displayed the snack-bar and then opened the dislog, I recommend you in this case to dismiss the snack-bar and re-show it. In this way you'll make sure that the snack bar is logically always the latest overlay, and will be displayed above all other overlay containers.

huangapple
  • 本文由 发表于 2023年6月6日 15:34:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412359.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定