diff --git a/src/Core/Components/CounterBadge/FluentCounterBadge.razor.cs b/src/Core/Components/CounterBadge/FluentCounterBadge.razor.cs
index 916034d0bc..fa2d2957e3 100644
--- a/src/Core/Components/CounterBadge/FluentCounterBadge.razor.cs
+++ b/src/Core/Components/CounterBadge/FluentCounterBadge.razor.cs
@@ -1,3 +1,7 @@
+// ------------------------------------------------------------------------
+// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
+// ------------------------------------------------------------------------
+
using System.Globalization;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components.Extensions;
@@ -18,9 +22,9 @@ public partial class FluentCounterBadge : FluentComponentBase, IDisposable
///
protected string? StyleValue => new StyleBuilder(Style)
- .AddStyle("left", $"{HorizontalPosition.ToString(CultureInfo.InvariantCulture)}%", () => GlobalState.Dir == LocalizationDirection.LeftToRight)
- .AddStyle("right", $"{HorizontalPosition.ToString(CultureInfo.InvariantCulture)}%", () => GlobalState.Dir == LocalizationDirection.RightToLeft)
- .AddStyle("bottom", $"{VerticalPosition.ToString(CultureInfo.InvariantCulture)}%")
+ .AddStyle("left", $"{HorizontalPosition?.ToString(CultureInfo.InvariantCulture)}%", () => GlobalState.Dir == LocalizationDirection.LeftToRight)
+ .AddStyle("right", $"{HorizontalPosition?.ToString(CultureInfo.InvariantCulture)}%", () => GlobalState.Dir == LocalizationDirection.RightToLeft)
+ .AddStyle("bottom", $"{VerticalPosition?.ToString(CultureInfo.InvariantCulture)}%")
.AddStyle("background-color", GetBackgroundColor().ToAttributeValue())
.AddStyle("color", GetFontColor().ToAttributeValue())
.AddStyle("border", $"1px solid {GetBorderColor().ToAttributeValue()}")
@@ -50,7 +54,7 @@ public partial class FluentCounterBadge : FluentComponentBase, IDisposable
/// Gets or sets the content you want inside the badge, to customize the badge content.
///
[Parameter]
- public RenderFragment? BadgeTemplate{ get; set; }
+ public RenderFragment? BadgeTemplate { get; set; }
///
/// Gets or sets the maximum number that can be displayed inside the badge.
@@ -64,7 +68,7 @@ public partial class FluentCounterBadge : FluentComponentBase, IDisposable
/// Default value is 60 (80 when Dot=true).
///
[Parameter]
- public int HorizontalPosition { get; set; }
+ public int? HorizontalPosition { get; set; }
///
/// Gets or sets the bottom position of the badge in percentage.
@@ -75,7 +79,7 @@ public partial class FluentCounterBadge : FluentComponentBase, IDisposable
[Parameter]
public int BottomPosition
{
- get => VerticalPosition;
+ get => VerticalPosition ?? 60;
set => VerticalPosition = value;
}
@@ -84,7 +88,7 @@ public int BottomPosition
/// Default value is 60 (80 when Dot=true).
///
[Parameter]
- public int VerticalPosition { get; set; }
+ public int? VerticalPosition { get; set; }
///
/// Gets or sets the default design of this badge using colors from theme.
@@ -160,8 +164,9 @@ protected override Task OnParametersSetAsync()
protected override void OnInitialized()
{
- HorizontalPosition = Dot ? 80 : 60;
- VerticalPosition = Dot ? 80 : 60;
+ HorizontalPosition ??= Dot ? 80 : 60;
+ VerticalPosition ??= Dot ? 80 : 60;
+
GlobalState.OnChange += StateHasChanged;
}
diff --git a/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_DotWithPositioning.verified.html b/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_DotWithPositioning.verified.html
new file mode 100644
index 0000000000..15b88fba16
--- /dev/null
+++ b/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_DotWithPositioning.verified.html
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_WithPositioning.verified.html b/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_WithPositioning.verified.html
new file mode 100644
index 0000000000..b3c160d061
--- /dev/null
+++ b/tests/Core/CounterBadge/FluentCounterBadgeTests.FluentCounterBadge_WithPositioning.verified.html
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/tests/Core/CounterBadge/FluentCounterBadgeTests.cs b/tests/Core/CounterBadge/FluentCounterBadgeTests.cs
index 27431e0c45..26b787c3bb 100644
--- a/tests/Core/CounterBadge/FluentCounterBadgeTests.cs
+++ b/tests/Core/CounterBadge/FluentCounterBadgeTests.cs
@@ -454,4 +454,39 @@ public void FluentCounterBadge_DotWithCount()
// Assert
cut.Verify();
}
+
+ [Fact]
+ public void FluentCounterBadge_DotWithPositioning()
+ {
+ // Arrange && Act
+ TestContext.Services.AddSingleton(GlobalState);
+
+ var cut = TestContext.RenderComponent(parameters =>
+ {
+ parameters.Add(p => p.Dot, true);
+ parameters.Add(p => p.Count, 1);
+ parameters.Add(parameters => parameters.HorizontalPosition, -25);
+ parameters.Add(parameters => parameters.VerticalPosition, -25);
+ });
+
+ // Assert
+ cut.Verify();
+ }
+
+ [Fact]
+ public void FluentCounterBadge_WithPositioning()
+ {
+ // Arrange && Act
+ TestContext.Services.AddSingleton(GlobalState);
+
+ var cut = TestContext.RenderComponent(parameters =>
+ {
+ parameters.Add(p => p.Count, 1);
+ parameters.Add(parameters => parameters.HorizontalPosition, -25);
+ parameters.Add(parameters => parameters.VerticalPosition, -25);
+ });
+
+ // Assert
+ cut.Verify();
+ }
}
diff --git a/tests/Core/Search/FluentSearchTests.cs b/tests/Core/Search/FluentSearchTests.cs
index b3d8558ac8..a7401e78be 100644
--- a/tests/Core/Search/FluentSearchTests.cs
+++ b/tests/Core/Search/FluentSearchTests.cs
@@ -1,3 +1,7 @@
+// ------------------------------------------------------------------------
+// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
+// ------------------------------------------------------------------------
+
using Bunit;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
@@ -12,7 +16,6 @@ public FluentSearchTests()
Services.AddSingleton(LibraryConfiguration.ForUnitTests);
}
-
[Fact]
public void FluentSearch_Default()
{