Open aDisplayName opened 2 years ago
I found a possible solution/reason. As stated in the following blog: https://www.daveabrock.com/2020/09/10/blazor-css-isolation
It states that you need to wrap a simple
<div>
<MudDialog Class="redhello">
<DialogContent>
<div>Hello</div>
<div class="redhello">the world</div>
</DialogContent>
</MudDialog>
</div>
This might be your solution.
Bug type
Component
Component name
MudDialog
What happened?
When displaying dialog using dialogbox service with a dialog template defined in a separate razor component, the class defined in the component css file are not correctly applied.
Here is the
Counter.razor
page which display the dialog when clicking the button.Here is the dialog component razor file:
Box.razor
And here is the style defined in the
Box.razor.css
Here is the result after the dialogbox is displayed.
And here is the DOM:
As we can see, that the "redhello" is applied to both muddialog, and the inner div, but due to the lack of
b-cgqs55320o
attribute in themuddialog
level, the style is not applied to the dialog level.I understand that the
b-cgqs55320o
comes from the CSS Isolation. The problem is I cannot figure it a way to apply the style contained in the component.razor.css when CSS isolation is not disabled.Expected behavior
The custom style is applied to the entire dialog:
Reproduction link
https://github.com/aDisplayName/bugsamplecode/tree/main/20220411
Reproduction steps
When displaying dialog using dialogbox service with a dialog template defined in a separate razor component, the class defined in the component css file are not correctly applied.
Here is the page which display the dialog when clicking the button.
Here is the dialog component razor file:
Box.razor
And here is the style defined in the
Box.razor.css
Here is the result after the dialogbox is displayed.
And here is the DOM:
As we can see, that the "redhello" is applied to both muddialog, and the inner div, but due to the lack of
b-cgqs55320o
attribute in themuddialog
level, the style is not applied to the dialog level.I understand that the
b-cgqs55320o
comes from the CSS Isolation. The problem is I cannot figure it a way to apply the style contained in the component.razor.css when CSS isolation is not disabled.Relevant log output
No response
Version (bug)
6.0.9
Version (working)
No response
What browsers are you seeing the problem on?
Microsoft Edge
On what operating system are you experiencing the issue?
Windows
Pull Request
Code of Conduct