From 4e6daf343d8708916945c74608be182f5378d15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Standa=20Luke=C5=A1?= Date: Thu, 8 Dec 2022 17:42:59 +0100 Subject: [PATCH] Fix RouteLink.UrlSuffix={value: Property} We have to unwrap the knockout observable before calling buildUrlSuffix or concatenating strings --- src/Framework/Framework/Controls/RouteLinkHelpers.cs | 2 +- src/Tests/ControlTests/SimpleControlTests.cs | 11 ++++++++--- .../testoutputs/SimpleControlTests.RouteLink.html | 10 ++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Framework/Framework/Controls/RouteLinkHelpers.cs b/src/Framework/Framework/Controls/RouteLinkHelpers.cs index 800bddff76..4281866015 100644 --- a/src/Framework/Framework/Controls/RouteLinkHelpers.cs +++ b/src/Framework/Framework/Controls/RouteLinkHelpers.cs @@ -131,7 +131,7 @@ public static string GenerateKnockoutHrefExpression(string routeName, RouteLink { var urlSuffixBase = control.GetValueBinding(RouteLink.UrlSuffixProperty) - ?.Apply(binding => binding.GetKnockoutBindingExpression(control)) + ?.Apply(binding => binding.GetKnockoutBindingExpression(control, unwrapped: true)) ?? KnockoutHelper.MakeStringLiteral(control.UrlSuffix ?? ""); var queryParamsArray = control.QueryParameters.RawValues.ToArray(); Array.Sort(queryParamsArray, (a, b) => a.Key.CompareTo(b.Key)); // deterministic order of query params diff --git a/src/Tests/ControlTests/SimpleControlTests.cs b/src/Tests/ControlTests/SimpleControlTests.cs index 710543e0f5..8d799d9228 100644 --- a/src/Tests/ControlTests/SimpleControlTests.cs +++ b/src/Tests/ControlTests/SimpleControlTests.cs @@ -33,6 +33,8 @@ public async Task RouteLink() + + @@ -40,22 +42,23 @@ public async Task RouteLink() + + - + - - + " @@ -458,6 +461,8 @@ public class BasicTestViewModel: DotvvmViewModelBase public int[] IntArray { get; set; } + public string UrlSuffix { get; set; } = "#something"; + public GridViewDataSet Customers { get; set; } = new GridViewDataSet() { RowEditOptions = { EditRowId = 1, diff --git a/src/Tests/ControlTests/testoutputs/SimpleControlTests.RouteLink.html b/src/Tests/ControlTests/testoutputs/SimpleControlTests.RouteLink.html index 813a61ad12..909266dd3b 100644 --- a/src/Tests/ControlTests/testoutputs/SimpleControlTests.RouteLink.html +++ b/src/Tests/ControlTests/testoutputs/SimpleControlTests.RouteLink.html @@ -11,6 +11,9 @@ My Label + + Click me + Click me @@ -20,6 +23,9 @@ My Label + + Click me + Click me @@ -27,7 +33,7 @@ Click me - Click me + Click me My Label @@ -39,7 +45,7 @@ Click me - Click me + Click me My Label