From b6052cceeefddd0a50173baa1ebaec159fa80806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Standa=20Luke=C5=A1?= Date: Wed, 7 Dec 2022 22:41:32 +0100 Subject: [PATCH] hierarchy repeater: fix client-side command in markup control problem was that that BindingHelper.FindDataContextTarget assumed there was one more data context layer since we used set data context type and DataContext on different controls. Because of that command client-side and server-side data context paths didn't match. Technically, this is a glitch of BindingHelper, not HierarchyRepeater, but "fixing" BindingHelper will break many things and it's hopefully going to be done in #1392 --- src/Framework/Framework/Controls/HierarchyRepeater.cs | 1 + ...chyRepeaterTests.CommandInMarkupControl-server.html | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Framework/Framework/Controls/HierarchyRepeater.cs b/src/Framework/Framework/Controls/HierarchyRepeater.cs index 39db3f82d5..520bad1a04 100644 --- a/src/Framework/Framework/Controls/HierarchyRepeater.cs +++ b/src/Framework/Framework/Controls/HierarchyRepeater.cs @@ -258,6 +258,7 @@ private void SetChildren(IDotvvmRequestContext context, bool renderClientTemplat Internal.PathFragmentProperty, $"{GetPathFragmentExpression()}{parentSegment}/[{index}]"); placeholder.SetValue(Internal.UniqueIDProperty, "item"); + placeholder.SetDataContextTypeFromDataSource(GetDataSourceBinding()); // DataContext type has to be duplicated on the placeholder, because BindingHelper.FindDataContextTarget (in v4.1) dataItem.Children.Add(placeholder); ItemTemplate.BuildContent(context, placeholder); diff --git a/src/Tests/ControlTests/testoutputs/HierarchyRepeaterTests.CommandInMarkupControl-server.html b/src/Tests/ControlTests/testoutputs/HierarchyRepeaterTests.CommandInMarkupControl-server.html index 290379db3d..c37b3bba11 100644 --- a/src/Tests/ControlTests/testoutputs/HierarchyRepeaterTests.CommandInMarkupControl-server.html +++ b/src/Tests/ControlTests/testoutputs/HierarchyRepeaterTests.CommandInMarkupControl-server.html @@ -4,19 +4,19 @@
-
+
-
+
-
+
-
+
-
+