Skip to content

Commit f92ebde

Browse files
committed
Merge branch 'bugfix/CurrentWebPath' into develop
Fixed bug with `NavigationViewModel<T>.CurrentWebPath` still being assigned to `Topic.GetUniqueKey()` instead of the `Topic.GetWebPath()`, as expected. This was permitted by faulty unit tests, which have also been fixed. This results in current navigation items not being properly selected, since they were comparing the `GetWebPath()` to `GetUniqueKey()`.
2 parents cc6eb67 + 619ba62 commit f92ebde

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

OnTopic.AspNetCore.Mvc.Tests/TopicViewComponentTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public async Task Menu_Invoke_ReturnsNavigationViewModel() {
114114
var model = concreteResult?.ViewData.Model as NavigationViewModel<NavigationTopicViewModel>;
115115

116116
Assert.IsNotNull(model);
117-
Assert.AreEqual<string?>(_topic.GetUniqueKey(), model?.CurrentWebPath);
117+
Assert.AreEqual<string?>(_topic.GetWebPath(), model?.CurrentWebPath);
118118
Assert.AreEqual<string?>("/Web/", model?.NavigationRoot?.WebPath);
119119
Assert.AreEqual<int?>(3, model?.NavigationRoot?.Children.Count);
120120
Assert.IsTrue(model?.NavigationRoot?.IsSelected(_topic.GetWebPath())?? false);
@@ -139,7 +139,7 @@ public async Task PageLevelNavigation_Invoke_ReturnsNavigationViewModel() {
139139
var model = concreteResult?.ViewData.Model as NavigationViewModel<NavigationTopicViewModel>;
140140

141141
Assert.IsNotNull(model);
142-
Assert.AreEqual<string?>(_topic.GetUniqueKey(), model?.CurrentWebPath);
142+
Assert.AreEqual<string?>(_topic.GetWebPath(), model?.CurrentWebPath);
143143
Assert.AreEqual<string?>("/Web/Web_3/", model?.NavigationRoot?.WebPath);
144144
Assert.AreEqual<int?>(2, model?.NavigationRoot?.Children.Count);
145145
Assert.IsTrue(model?.NavigationRoot?.IsSelected(_topic.GetWebPath())?? false);

OnTopic.AspNetCore.Mvc/Components/MenuViewComponentBase{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task<IViewComponentResult> InvokeAsync() {
131131
\-----------------------------------------------------------------------------------------------------------------------*/
132132
var navigationViewModel = new NavigationViewModel<T>() {
133133
NavigationRoot = await MapNavigationTopicViewModels(navigationRootTopic).ConfigureAwait(true),
134-
CurrentWebPath = CurrentTopic?.GetUniqueKey()?? HttpContext.Request.Path
134+
CurrentWebPath = CurrentTopic?.GetWebPath()?? HttpContext.Request.Path
135135
};
136136

137137
/*------------------------------------------------------------------------------------------------------------------------

OnTopic.AspNetCore.Mvc/Components/PageLevelNavigationViewComponentBase{T}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public async Task<IViewComponentResult> InvokeAsync() {
128128
\-----------------------------------------------------------------------------------------------------------------------*/
129129
var navigationViewModel = new NavigationViewModel<T>() {
130130
NavigationRoot = await MapNavigationTopicViewModels(navigationRootTopic).ConfigureAwait(true),
131-
CurrentWebPath = CurrentTopic?.GetUniqueKey()?? HttpContext.Request.Path
131+
CurrentWebPath = CurrentTopic?.GetWebPath()?? HttpContext.Request.Path
132132
};
133133

134134
/*------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)