-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: FluentBadge content alignment when component is static #1749
Comments
So the div that contains the content is not placed in the shadow DOM in SSR mode. I don't think that's really strange but also don't know yet why that is the case. @swegele 's assumption that all 3 render modes should look the same is a nice one but not necessariy true in practice. We have not claimed anywhere that all components work in SSR mode. |
I actually thought about if the different behavior here was logical due to lack of interactivity (example: obviously the button doesn't do anything but that is expected). Couldn't think of a reason why it would render differently....so just passing it on. 😃 Thanks again for your work on this. I'm adopting it in upcoming projects. |
@vnbaaij I just noticed something that maybe gives a hint. I deleted cache and loaded a counter page set for: So it does look like the "div" tag literally gets moved inside the badge component during subsequent rendering. |
It looks like the issue is in the underlying |
The flicker you are seeing is the transition from the initial static rendering generated by the server to the rendering generated by Blazor. All the interactive modes of Blazor Web Apps initially do a static render. This issue makes it more visually apparent. |
I downloaded the source and took a gander. I was unable to determine why it would ever render content outside the tag. _P.S. I also realized how there are some very smart people out there! This is very well organized code with tests and auto-documenting etc. A little above my head too! |
It appears the underlying issue is in the fluent-badge web component. If the fluent-badge component is enclosed in a p tag, this issue appears. The issue doesn't appear when enclosde in a div tag. ReproCode@page "/staticcounter"
@* @rendermode InteractiveAuto *@
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: <FluentBadge Appearance="Appearance.Neutral">@currentCount</FluentBadge></p>
<FluentButton Appearance="Appearance.Accent" @onclick="IncrementCount">Click me</FluentButton>
<hr />
<h2>Repro</h2>
<p>Explicitly using fluent-badge</p>
<h3>Original</h3>
<p>
Test #1:
<fluent-badge>
<div>@currentCount</div>
</fluent-badge>
</p>
<h3>Workaround</h3>
<div>
Test #2:
<fluent-badge>
<div>@currentCount</div>
</fluent-badge>
</div>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
} ResultsAs to why this doesn't appear when not statically rendered, I suspect it has something to do with the way Blazor DOM is created. I'm guessing the leaf nodes are created first. @vnbaaij Is this a fluent-badge bug? |
The workaround would be replacing <p role="status">Current count: <FluentBadge Appearance="Appearance.Neutral">@currentCount</FluentBadge></p> with <div role="status" style="padding-bottom: 1em;">
Current count: <FluentBadge Appearance="Appearance.Neutral">@currentCount</FluentBadge>
</div> |
Great find Gary! I'm not sue if this is really a web component bug. Looking at the source at https://github.com/microsoft/fast/tree/archives/fast-element-1/packages/web-components/fast-foundation/src/badge, I can only conclude that this is about the simplest webcomponent of all of them. And besides, the web component has no influence on what it is surrounded with so I'm more inclined to think it is actually a Blazor thing. |
I've implemented the replacing of the As we have a workaround with that, I'm closing this one for now. |
thanks to you both! |
Will you create an issue for it in the Fluent UI repo? |
Given that I filed this as an issue in the fluentui repo, can we re-open this and add labels |
When using HorizontalPosition and/or VerticalPosition it still has an issue
|
Love the controls!!
🐛 Bug Report
Counter page FluentBadge alignment is skewed when page is rendered statically
SERVER and WASM INTERACTIVE:

STATIC:

💻 Repro or Code Sample
🤔 Expected Behavior
All 3 render modes should look the same
😯 Current Behavior
Static is different
Upon inspecting elements, it looks like the "0" div ends up outside the badge container.
🔦 Context
Latest version of controls/nuget
The text was updated successfully, but these errors were encountered: