Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6692,6 +6692,13 @@
Gets or sets the button appearance.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.ButtonContent">
<summary>
The content to be rendered inside the button. This parameter should be supplied if you do not want to render a chevron
on the menu button.
If both <see cref="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.Text"/> and ButtonContent are provided, ButtonContent will be used.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.Menu">
<summary>
Gets or sets a reference to the menu.
Expand All @@ -6706,7 +6713,8 @@
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.Text">
<summary>
Gets or sets the texts shown on th button.
Gets or sets the texts shown on the button.
If both Text and<see cref = "P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.ButtonContent" /> are provided, ButtonContent will be used.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuButton.IconStart">
Expand Down Expand Up @@ -6880,7 +6888,7 @@
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.SetOpenAsync(System.Boolean)">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.Dispose">
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.DisposeAsync">
<summary>
Dispose this menu.
</summary>
Expand Down
23 changes: 10 additions & 13 deletions src/Core/Components/MenuButton/FluentMenuButton.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public partial class FluentMenuButton : FluentComponentBase
[Parameter]
public Appearance ButtonAppearance { get; set; } = Appearance.Accent;

/// <summary>
/// The content to be rendered inside the button. This parameter should be supplied if you do not want to render a chevron
/// on the menu button.
/// If both <see cref="Text"/> and ButtonContent are provided, ButtonContent will be used.
/// </summary>
[Parameter]
public RenderFragment? ButtonContent { get; set; }

/// <summary>
/// Gets or sets a reference to the menu.
/// </summary>
Expand All @@ -44,7 +52,8 @@ public partial class FluentMenuButton : FluentComponentBase
public bool UseMenuService { get; set; } = true;

/// <summary>
/// Gets or sets the texts shown on the button. This property will be ignored if <see cref="ButtonContent"/> is provided.
/// Gets or sets the texts shown on the button.
/// If both Text and<see cref = "ButtonContent" /> are provided, ButtonContent will be used.
/// </summary>
[Parameter]
public string? Text { get; set; }
Expand Down Expand Up @@ -87,25 +96,13 @@ public partial class FluentMenuButton : FluentComponentBase
[Parameter]
public EventCallback<MenuChangeEventArgs> OnMenuChanged { get; set; }

/// <summary>
/// The content to be rendered inside the button. This parameter should be supplied if you do not want to render a chevron
/// on the menu button. Only one of <see cref="Text"/> or <see cref="ButtonContent"/> may be provided.
/// </summary>
[Parameter]
public RenderFragment? ButtonContent { get; set; }

protected override void OnInitialized()
{
_buttonId = Identifier.NewId();
}

protected override void OnParametersSet()
{
if (Text is not null && ButtonContent is not null)
{
throw new ArgumentException($"Only one of the parameters {nameof(Text)} or {nameof(ButtonContent)} can be provided.");
}

_iconColor = ButtonAppearance == Appearance.Accent ? Color.Fill : Color.FillInverse;
}

Expand Down
16 changes: 0 additions & 16 deletions tests/Core/_ToDo/MenuButton/FluentMenuButtonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,6 @@ public void FluentMenuButton_IconStart()
cut.Verify();
}

[Fact]
public void FluentMenuButton_Throws_IfBothTextAndButtonContentAreSet()
{
Assert.Throws<ArgumentException>(() =>
{
TestContext.RenderComponent<FluentMenuButton>(parameters => parameters
.Add(p => p.Text, "Button Text")
.Add<RenderFragment>(p => p.ButtonContent, builder =>
{
builder.OpenComponent<FluentMenuItem>(0);
builder.AddAttribute(1, "Text", "Menu Item 1");
builder.CloseComponent();
})
);
});
}

[Fact]
public void FluentMenuButton_Renders_ButtonContent()
Expand Down
Loading