You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then use it similarly to the example from the Demo site:
<p>With icon in default slot</p>
<WrapperFluentButtonIconEnd="@(new Icons.Regular.Size16.Globe())"Title="Globe" />
馃 Expected Behavior
The following button should be rendered:
馃槸 Current Behavior
The following button will be rendered:
馃拋 Possible Solution
This happens, to the best of my knowledge, because the icon ends up being placed in the end slot, not the default slot. And that, to the best of my knowledge, may be happening because the conditions below in FluentButton.razor seem to always evaluate to true in this context.
In FluentButton.razor, you have the following conditions:
Both the conditions above use ChildContent != null.
If a parent component wraps FluentButton and passes an empty ChildContent to FluentButton, those conditions seem to always evaluate to true. I'm not sure why, though.
As a workaround, an if statement in the wrapper's razor file will solve it, as per the solution at the end of this issue.
馃敠 Context
I'm trying to wrap the FluentButton inside my own customized button.
馃實 Your Environment
OS & Device: MacOS
Browser: Apple Safari
.NET and Fluent UI Blazor library Version [8.0.2 and 4.7.2]
The text was updated successfully, but these errors were encountered:
Though I do believe the source of the problem was correctly pointed out, the potential solution I initially suggested (use ChildContent?.HasDelegate == true, instead of ChildContent != null in FluentButton.razor) apparently wouldn't compile. I ended up just using an if statement in the wrapper's razor file and it worked:
luissalgadofreire
changed the title
fix: use ChildContent?.HasDelegate == true, instead of ChildContent != null in **FluentButton.razor**
fix: Icon in default slot will not render correctly in FluentButton.razor if component is wrapped inside another
May 27, 2024
馃悰 Bug Report
Calling
FluentButton
wrapped inside another component like:does not place the icon in the
default
slot, but in theend
slot.馃捇 Repro or Code Sample
Create a WrapperFluentButton.razor with code:
Then use it similarly to the example from the Demo site:
馃 Expected Behavior
The following button should be rendered:
馃槸 Current Behavior
The following button will be rendered:
馃拋 Possible Solution
This happens, to the best of my knowledge, because the icon ends up being placed in the
end
slot, not thedefault
slot. And that, to the best of my knowledge, may be happening because the conditions below in FluentButton.razor seem to always evaluate totrue
in this context.In FluentButton.razor, you have the following conditions:
Both the conditions above use
ChildContent != null
.If a parent component wraps
FluentButton
and passes an emptyChildContent
toFluentButton
, those conditions seem to always evaluate totrue
. I'm not sure why, though.As a workaround, an if statement in the wrapper's razor file will solve it, as per the solution at the end of this issue.
馃敠 Context
I'm trying to wrap the
FluentButton
inside my own customized button.馃實 Your Environment
The text was updated successfully, but these errors were encountered: