Closed jolaquai closed 1 month ago
Title. Repo link with minimal sample that reproduces the issue can be found here: jolaquai/HxToastDangerMessageProblem
While I have no idea about the nitty-gritty of Blazor or Component development, wading through the Blazor and Havit.Blazor sources showed that the exception comes from Havit.Blazor.Components.Web.Bootstrap.HxToast.BuildRenderTree(RenderTreeBuilder) because for ThemeColor.Danger, HasContrastColor() returns true.
Havit.Blazor.Components.Web.Bootstrap.HxToast.BuildRenderTree(RenderTreeBuilder)
ThemeColor.Danger
HasContrastColor()
true
This causes BuildRenderTree(RenderTreeBuilder) to attempt to write data-bs-theme="dark" into the "last non-attribute frame" (which is currently a RenderTreeFrameType.Region), which obviously fails Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AssertCanAddAttribute().
BuildRenderTree(RenderTreeBuilder)
data-bs-theme="dark"
RenderTreeFrameType.Region
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AssertCanAddAttribute()
@crdo Fixed the crash, but probably needs some more work on visual result:
@jolaquai Thanks for reporting the issue. We were able to reproduce the crash and will fix it for the next release.
Title. Repo link with minimal sample that reproduces the issue can be found here: jolaquai/HxToastDangerMessageProblem
While I have no idea about the nitty-gritty of Blazor or Component development, wading through the Blazor and Havit.Blazor sources showed that the exception comes from
Havit.Blazor.Components.Web.Bootstrap.HxToast.BuildRenderTree(RenderTreeBuilder)
because forThemeColor.Danger
,HasContrastColor()
returnstrue
.This causes
BuildRenderTree(RenderTreeBuilder)
to attempt to writedata-bs-theme="dark"
into the "last non-attribute frame" (which is currently aRenderTreeFrameType.Region
), which obviously failsMicrosoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AssertCanAddAttribute()
.