From db5727af4d814cfd81cef862961b3f43a7eb8f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Larivi=C3=A8re?= Date: Mon, 4 Mar 2024 09:37:52 +0100 Subject: [PATCH 1/4] Include Memo.KeyData in CanReuseMemo --- src/Fabulous/Memo.fs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Fabulous/Memo.fs b/src/Fabulous/Memo.fs index f961a82dd..ce37b7aac 100644 --- a/src/Fabulous/Memo.fs +++ b/src/Fabulous/Memo.fs @@ -59,7 +59,11 @@ module Memo = | _ -> failwith "Memo widget cannot have extra attributes" let internal canReuseMemoizedWidget prev next = - (getMemoData prev).MarkerType = (getMemoData next).MarkerType + let prevMemoData = getMemoData prev + let currMemoData = getMemoData next + + prevMemoData.MarkerType = currMemoData.MarkerType + && prevMemoData.KeyData = currMemoData.KeyData let internal MemoAttribute: SimpleScalarAttributeDefinition = { Key = MemoAttributeKey From 05471a37b26e1377491eb21d44b1f85a46d34fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Larivi=C3=A8re?= Date: Mon, 4 Mar 2024 09:47:54 +0100 Subject: [PATCH 2/4] Format code --- src/Fabulous/Memo.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fabulous/Memo.fs b/src/Fabulous/Memo.fs index ce37b7aac..dfc2ed9f7 100644 --- a/src/Fabulous/Memo.fs +++ b/src/Fabulous/Memo.fs @@ -61,7 +61,7 @@ module Memo = let internal canReuseMemoizedWidget prev next = let prevMemoData = getMemoData prev let currMemoData = getMemoData next - + prevMemoData.MarkerType = currMemoData.MarkerType && prevMemoData.KeyData = currMemoData.KeyData From 5c3519857b627b5e8402be1b549ab3a7659489e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Larivi=C3=A8re?= Date: Mon, 4 Mar 2024 11:26:20 +0100 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11ffdb14e..c9247f6b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _No unreleased changes_ +## [2.4.2] - 2024-03-04 + +### Changed +- Include Memo.KeyData in CanReuseMemo by @TimLariviere (https://github.com/fabulous-dev/Fabulous/pull/1071) + ## [2.4.1] - 2024-01-29 ### Added @@ -55,7 +60,8 @@ _No unreleased changes_ ### Changed - Fabulous.XamarinForms & Fabulous.MauiControls have been moved been out of the Fabulous repository. Find them in their own repositories: [https://github.com/fabulous-dev/Fabulous.XamarinForms](https://github.com/fabulous-dev/Fabulous.XamarinForms) / [https://github.com/fabulous-dev/Fabulous.MauiControls](https://github.com/fabulous-dev/Fabulous.MauiControls) -[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.4.1...HEAD +[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.4.2...HEAD +[2.4.2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.2 [2.4.1]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.1 [2.4.0]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.0 [2.3.2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.3.2 From 98fcda82719751bcd0241c946856091a31a24df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Larivi=C3=A8re?= Date: Mon, 4 Mar 2024 11:59:19 +0100 Subject: [PATCH 4/4] Fix unit tests --- src/Fabulous.Tests/APISketchTests/APISketchTests.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Fabulous.Tests/APISketchTests/APISketchTests.fs b/src/Fabulous.Tests/APISketchTests/APISketchTests.fs index c3c8b83b7..8091779b4 100644 --- a/src/Fabulous.Tests/APISketchTests/APISketchTests.fs +++ b/src/Fabulous.Tests/APISketchTests/APISketchTests.fs @@ -445,6 +445,7 @@ module MemoTests = instance.ProcessMessage(SetMemoPart 99) // rerendered because of memo key changed + let memoLabel = find tree "memo" :> IText Assert.AreEqual(2, renderCount) Assert.AreEqual("99", memoLabel.Text) @@ -534,11 +535,11 @@ module MemoTests = let labelAgain = find tree "label" - // same instance - Assert.AreSame(label, labelAgain) + // not same instance + Assert.AreNotSame(label, labelAgain) // just changes text but kept the same color - Assert.AreEqual([ TextSet "one"; ColorSet "blue"; TextSet "two" ], label.changeList) + Assert.AreEqual([ TextSet "two"; ColorSet "blue" ], labelAgain.changeList)