From 708c0b5b8cf752bca3dc1fa2bfd6a0b8781c6e57 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 10 Jul 2025 13:36:52 +0000
Subject: [PATCH 1/7] Initial plan
From ee5c4d1fb3d8cbc0bd3674ea8f12a3f089127486 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 10 Jul 2025 13:44:50 +0000
Subject: [PATCH 2/7] Add keyboard navigation handling to FluentNavLink inside
FluentNavGroup
Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
---
.../Components/NavMenu/FluentNavLink.razor | 8 ++-
.../Components/NavMenu/FluentNavLink.razor.cs | 9 +++
tests/Core/NavMenu/FluentNavLinkTests.cs | 63 +++++++++++++++++++
3 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/src/Core/Components/NavMenu/FluentNavLink.razor b/src/Core/Components/NavMenu/FluentNavLink.razor
index f84e437d52..668c97e740 100644
--- a/src/Core/Components/NavMenu/FluentNavLink.razor
+++ b/src/Core/Components/NavMenu/FluentNavLink.razor
@@ -9,7 +9,13 @@
@if (!OnClick.HasDelegate && Href is not null)
{
-
+ }
+
(parameters =>
+ {
+ parameters.Add(p => p.Owner, m);
+ parameters.Add(p => p.Href, "/example-page");
+ parameters.AddChildContent("NavLink text");
+ });
+
+ // Assert
+ cut.Verify();
+
+ // Verify that FluentKeyCode is added when Owner is not null and Href is set
+ var fluentKeyCode = cut.FindComponent();
+ Assert.NotNull(fluentKeyCode);
+
+ // Verify the anchor points to the NavLink element
+ var navLinkId = cut.Find("a[id]").GetAttribute("id");
+ Assert.Contains("navlink", navLinkId);
+ }
+
+ [Fact]
+ public void FluentNavLink_KeyboardNavigation_InsideNavGroup()
+ {
+ // This test simulates the issue scenario: FluentNavLink inside FluentNavGroup
+ var navMenuMarkup = @"
+
+ Example page
+
+ Example page
+
+ ";
+
+ // Arrange & Act
+ var cut = TestContext.RenderComponent(navMenuMarkup);
+
+ // Assert - Verify that both NavLinks are rendered correctly
+ var navLinks = cut.FindComponents();
+ Assert.Equal(2, navLinks.Count);
+
+ // The NavLink inside the group should have keyboard handling
+ var navLinkInGroup = navLinks[1]; // Second NavLink is inside the group
+ var fluentKeyCode = navLinkInGroup.FindComponent();
+ Assert.NotNull(fluentKeyCode);
+
+ // The standalone NavLink should not have keyboard handling (Owner is null)
+ var standaloneNavLink = navLinks[0]; // First NavLink is standalone
+ Assert.Throws(() => standaloneNavLink.FindComponent());
+ }
+
//ActiveClass
//Match
//Target
From dbedea889e7a718b93841f63ab34223ee6d9dc46 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 10 Jul 2025 13:47:44 +0000
Subject: [PATCH 3/7] Changes before error encountered
Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
---
tests/Core/NavMenu/FluentNavLinkTests.cs | 60 ++++++++++++++++--------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.cs b/tests/Core/NavMenu/FluentNavLinkTests.cs
index b4da8a0a69..02248ff2ad 100644
--- a/tests/Core/NavMenu/FluentNavLinkTests.cs
+++ b/tests/Core/NavMenu/FluentNavLinkTests.cs
@@ -216,30 +216,50 @@ public void FluentNavLink_InsideNavGroup_WithHref()
[Fact]
public void FluentNavLink_KeyboardNavigation_InsideNavGroup()
{
- // This test simulates the issue scenario: FluentNavLink inside FluentNavGroup
- var navMenuMarkup = @"
-
- Example page
-
- Example page
-
- ";
+ // Arrange & Act - Test NavLink inside a NavGroup scenario
+ var m = new FluentNavMenu
+ {
+ Expanded = true
+ };
+ var cut = TestContext.RenderComponent(parameters =>
+ {
+ parameters.Add(p => p.Owner, m);
+ parameters.Add(p => p.Href, "/example-page");
+ parameters.AddChildContent("Example page");
+ });
- // Arrange & Act
- var cut = TestContext.RenderComponent(navMenuMarkup);
+ // Assert - Verify that keyboard handling is added for NavLink inside group
+ cut.Verify();
+
+ // Verify FluentKeyCode component is present
+ var fluentKeyCode = cut.FindComponent();
+ Assert.NotNull(fluentKeyCode);
+
+ // Verify the NavLink has the expected id
+ var navLink = cut.Find("a[id]");
+ var navLinkId = navLink.GetAttribute("id");
+ Assert.Contains("-navlink", navLinkId);
+ }
- // Assert - Verify that both NavLinks are rendered correctly
- var navLinks = cut.FindComponents();
- Assert.Equal(2, navLinks.Count);
+ [Fact]
+ public void FluentNavLink_KeyboardNavigation_Standalone()
+ {
+ // Arrange & Act - Test standalone NavLink (no Owner)
+ var cut = TestContext.RenderComponent(parameters =>
+ {
+ parameters.Add(p => p.Href, "/example-page");
+ parameters.AddChildContent("Example page");
+ });
- // The NavLink inside the group should have keyboard handling
- var navLinkInGroup = navLinks[1]; // Second NavLink is inside the group
- var fluentKeyCode = navLinkInGroup.FindComponent();
- Assert.NotNull(fluentKeyCode);
+ // Assert - Verify that no keyboard handling is added for standalone NavLink
+ cut.Verify();
+
+ // Verify no FluentKeyCode component is present
+ Assert.Throws(() => cut.FindComponent());
- // The standalone NavLink should not have keyboard handling (Owner is null)
- var standaloneNavLink = navLinks[0]; // First NavLink is standalone
- Assert.Throws(() => standaloneNavLink.FindComponent());
+ // Verify the NavLink doesn't have the special id (should not have id attribute)
+ var navLink = cut.Find("a");
+ Assert.False(navLink.HasAttribute("id"), "Standalone NavLink should not have an id attribute");
}
//ActiveClass
From 698603e6ebc5bf69c029d800ae560d59493ffefa Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 10 Jul 2025 14:49:52 +0000
Subject: [PATCH 4/7] Add Space key support to FluentNavLink keyboard
navigation
Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
---
src/Core/Components/NavMenu/FluentNavLink.razor | 2 +-
src/Core/Components/NavMenu/FluentNavLink.razor.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Core/Components/NavMenu/FluentNavLink.razor b/src/Core/Components/NavMenu/FluentNavLink.razor
index 668c97e740..c32e7585d9 100644
--- a/src/Core/Components/NavMenu/FluentNavLink.razor
+++ b/src/Core/Components/NavMenu/FluentNavLink.razor
@@ -12,7 +12,7 @@
@* Add keyboard handling for navigation when inside a NavGroup *@
@if (Owner != null)
{
-
+
}
Date: Thu, 10 Jul 2025 21:26:29 +0000
Subject: [PATCH 5/7] Generate unique Id in FluentNavLink constructor for
keyboard handling
Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
---
src/Core/Components/NavMenu/FluentNavLink.razor.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Core/Components/NavMenu/FluentNavLink.razor.cs b/src/Core/Components/NavMenu/FluentNavLink.razor.cs
index a5f593b4b1..02bfe29602 100644
--- a/src/Core/Components/NavMenu/FluentNavLink.razor.cs
+++ b/src/Core/Components/NavMenu/FluentNavLink.razor.cs
@@ -32,6 +32,7 @@ public partial class FluentNavLink : FluentNavBase
public FluentNavLink()
{
+ Id = Identifier.NewId();
_renderContent = RenderContent;
}
From c70059cdaa9b4deb1fce37eac162928aa1c00a2c Mon Sep 17 00:00:00 2001
From: Vincent Baaij
Date: Sun, 13 Jul 2025 10:50:55 +0200
Subject: [PATCH 6/7] Add missing using
---
tests/Core/NavMenu/FluentNavLinkTests.cs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.cs b/tests/Core/NavMenu/FluentNavLinkTests.cs
index 02248ff2ad..c3d2a2da1f 100644
--- a/tests/Core/NavMenu/FluentNavLinkTests.cs
+++ b/tests/Core/NavMenu/FluentNavLinkTests.cs
@@ -2,6 +2,7 @@
// This file is licensed to you under the MIT License.
// ------------------------------------------------------------------------
using Bunit;
+using Bunit.Rendering;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.DependencyInjection;
@@ -203,11 +204,11 @@ public void FluentNavLink_InsideNavGroup_WithHref()
// Assert
cut.Verify();
-
+
// Verify that FluentKeyCode is added when Owner is not null and Href is set
var fluentKeyCode = cut.FindComponent();
Assert.NotNull(fluentKeyCode);
-
+
// Verify the anchor points to the NavLink element
var navLinkId = cut.Find("a[id]").GetAttribute("id");
Assert.Contains("navlink", navLinkId);
@@ -230,11 +231,11 @@ public void FluentNavLink_KeyboardNavigation_InsideNavGroup()
// Assert - Verify that keyboard handling is added for NavLink inside group
cut.Verify();
-
+
// Verify FluentKeyCode component is present
var fluentKeyCode = cut.FindComponent();
Assert.NotNull(fluentKeyCode);
-
+
// Verify the NavLink has the expected id
var navLink = cut.Find("a[id]");
var navLinkId = navLink.GetAttribute("id");
@@ -253,10 +254,10 @@ public void FluentNavLink_KeyboardNavigation_Standalone()
// Assert - Verify that no keyboard handling is added for standalone NavLink
cut.Verify();
-
+
// Verify no FluentKeyCode component is present
Assert.Throws(() => cut.FindComponent());
-
+
// Verify the NavLink doesn't have the special id (should not have id attribute)
var navLink = cut.Find("a");
Assert.False(navLink.HasAttribute("id"), "Standalone NavLink should not have an id attribute");
From 5e7331a6ed9d100775997f57782fd02d56a48dfd Mon Sep 17 00:00:00 2001
From: Vincent Baaij
Date: Sun, 13 Jul 2025 12:01:17 +0200
Subject: [PATCH 7/7] Update tests and verified files
---
...luentNavLink_InsideNavGroup_WithHref.verified.html | 11 +++++++++++
...nk_KeyboardNavigation_InsideNavGroup.verified.html | 11 +++++++++++
...avLink_KeyboardNavigation_Standalone.verified.html | 11 +++++++++++
tests/Core/NavMenu/FluentNavLinkTests.cs | 4 ----
4 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_InsideNavGroup_WithHref.verified.html
create mode 100644 tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_InsideNavGroup.verified.html
create mode 100644 tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_Standalone.verified.html
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_InsideNavGroup_WithHref.verified.html b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_InsideNavGroup_WithHref.verified.html
new file mode 100644
index 0000000000..19f9442c4c
--- /dev/null
+++ b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_InsideNavGroup_WithHref.verified.html
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_InsideNavGroup.verified.html b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_InsideNavGroup.verified.html
new file mode 100644
index 0000000000..82519a63bf
--- /dev/null
+++ b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_InsideNavGroup.verified.html
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_Standalone.verified.html b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_Standalone.verified.html
new file mode 100644
index 0000000000..82519a63bf
--- /dev/null
+++ b/tests/Core/NavMenu/FluentNavLinkTests.FluentNavLink_KeyboardNavigation_Standalone.verified.html
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/tests/Core/NavMenu/FluentNavLinkTests.cs b/tests/Core/NavMenu/FluentNavLinkTests.cs
index c3d2a2da1f..156bac5d58 100644
--- a/tests/Core/NavMenu/FluentNavLinkTests.cs
+++ b/tests/Core/NavMenu/FluentNavLinkTests.cs
@@ -257,10 +257,6 @@ public void FluentNavLink_KeyboardNavigation_Standalone()
// Verify no FluentKeyCode component is present
Assert.Throws(() => cut.FindComponent());
-
- // Verify the NavLink doesn't have the special id (should not have id attribute)
- var navLink = cut.Find("a");
- Assert.False(navLink.HasAttribute("id"), "Standalone NavLink should not have an id attribute");
}
//ActiveClass