Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.31k stars 533 forks source link

Conditional Markdown-Element will not hide and duplicated #3310

Closed WolfgangKluge closed 2 years ago

WolfgangKluge commented 2 years ago

Describe the bug I have a markdown Element and try to display it conditionally. If the condition changes, the element will not hide and sometimes there are multiple elements.

To Reproduce use


<Button Clicked="@(() => visible = !visible)">@visible</Button>
@if (visible) {
    <Blazorise.Markdown.Markdown />
}

@code {
    private bool visible;
}

If you switch visible from false to true and the markdown editor will be loaded.. After turning visible back to false, the editor is still visible... Turning it to true again, a second (third, ...) markdown editor will appear.

Expected behavior It would be great, if the Element behaves like every other element. But I understand that there are several new html-elements generated by using <Blazorise.Markdown.Markdown />.. So maybe this should not work this way.

I tried it with Display as well

<Blazorise.Markdown.Markdown Display="@(visible ? Display.Always : Display.None)" />

But it seems to not be relevant for the Markdown-Extension (= the value is not passed through to the editor component). The component is visible from the start and never hides.

Workaround As a workaround I use a container Element like

<Card Display="@(visible ? Display.Always : Display.None)">
    <Blazorise.Markdown.Markdown />
</Card>
stsrki commented 2 years ago

This seems like the Blazor thing doing its job. Maybe the component is not properly disposed of. I will investigate.