diff --git a/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/Components/NavRailSection.razor b/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/Components/NavRailSection.razor
index bbeced4..5c1dcf4 100644
--- a/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/Components/NavRailSection.razor
+++ b/ZB.MOM.WW.Theme/src/ZB.MOM.WW.Theme/Components/NavRailSection.razor
@@ -31,8 +31,9 @@
private string ResolvedKey => string.IsNullOrWhiteSpace(Key) ? Slug(Title) : Key!;
- private static string Slug(string s)
+ private static string Slug(string? s)
{
+ if (string.IsNullOrWhiteSpace(s)) return string.Empty;
var chars = s.Trim().ToLowerInvariant()
.Select(c => char.IsLetterOrDigit(c) ? c : '-').ToArray();
return string.Join('-', new string(chars).Split('-', StringSplitOptions.RemoveEmptyEntries));
diff --git a/ZB.MOM.WW.Theme/tests/ZB.MOM.WW.Theme.Tests/NavRailTests.cs b/ZB.MOM.WW.Theme/tests/ZB.MOM.WW.Theme.Tests/NavRailTests.cs
index 017215f..6b0d86f 100644
--- a/ZB.MOM.WW.Theme/tests/ZB.MOM.WW.Theme.Tests/NavRailTests.cs
+++ b/ZB.MOM.WW.Theme/tests/ZB.MOM.WW.Theme.Tests/NavRailTests.cs
@@ -73,4 +73,22 @@ public class NavRailTests : TestContext
.AddChildContent("X"));
Assert.Equal("nav", cut.Find("details.rail-section").GetAttribute("data-nav-key"));
}
+
+ [Fact]
+ public void NavRailSection_whitespace_only_title_yields_empty_data_nav_key()
+ {
+ var cut = RenderComponent(p => p
+ .Add(x => x.Title, " ")
+ .AddChildContent("X"));
+ Assert.Equal("", cut.Find("details.rail-section").GetAttribute("data-nav-key"));
+ }
+
+ [Fact]
+ public void NavRailSection_slug_preserves_unicode_letters()
+ {
+ var cut = RenderComponent(p => p
+ .Add(x => x.Title, "Café")
+ .AddChildContent("X"));
+ Assert.Equal("café", cut.Find("details.rail-section").GetAttribute("data-nav-key"));
+ }
}