Skip to content

Commit 2bae3c3

Browse files
authored
Merge pull request #1071 from fabulous-dev/improve-memo-reuse
Include Memo.KeyData in CanReuseMemo
2 parents 45ac759 + 98fcda8 commit 2bae3c3

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
_No unreleased changes_
1111

12+
## [2.4.2] - 2024-03-04
13+
14+
### Changed
15+
- Include Memo.KeyData in CanReuseMemo by @TimLariviere (https://github.com/fabulous-dev/Fabulous/pull/1071)
16+
1217
## [2.4.1] - 2024-01-29
1318

1419
### Added
@@ -55,7 +60,8 @@ _No unreleased changes_
5560
### Changed
5661
- 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)
5762

58-
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.4.1...HEAD
63+
[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/2.4.2...HEAD
64+
[2.4.2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.2
5965
[2.4.1]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.1
6066
[2.4.0]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.4.0
6167
[2.3.2]: https://github.com/fabulous-dev/Fabulous/releases/tag/2.3.2

src/Fabulous.Tests/APISketchTests/APISketchTests.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ module MemoTests =
445445
instance.ProcessMessage(SetMemoPart 99)
446446

447447
// rerendered because of memo key changed
448+
let memoLabel = find<TestLabel> tree "memo" :> IText
448449
Assert.AreEqual(2, renderCount)
449450
Assert.AreEqual("99", memoLabel.Text)
450451

@@ -534,11 +535,11 @@ module MemoTests =
534535

535536
let labelAgain = find<TestLabel> tree "label"
536537

537-
// same instance
538-
Assert.AreSame(label, labelAgain)
538+
// not same instance
539+
Assert.AreNotSame(label, labelAgain)
539540

540541
// just changes text but kept the same color
541-
Assert.AreEqual([ TextSet "one"; ColorSet "blue"; TextSet "two" ], label.changeList)
542+
Assert.AreEqual([ TextSet "two"; ColorSet "blue" ], labelAgain.changeList)
542543

543544

544545

src/Fabulous/Memo.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ module Memo =
5959
| _ -> failwith "Memo widget cannot have extra attributes"
6060

6161
let internal canReuseMemoizedWidget prev next =
62-
(getMemoData prev).MarkerType = (getMemoData next).MarkerType
62+
let prevMemoData = getMemoData prev
63+
let currMemoData = getMemoData next
64+
65+
prevMemoData.MarkerType = currMemoData.MarkerType
66+
&& prevMemoData.KeyData = currMemoData.KeyData
6367

6468
let internal MemoAttribute: SimpleScalarAttributeDefinition<MemoData> =
6569
{ Key = MemoAttributeKey

0 commit comments

Comments
 (0)