Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Memo.KeyData in CanReuseMemo #1071

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Fabulous.Tests/APISketchTests/APISketchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ module MemoTests =
instance.ProcessMessage(SetMemoPart 99)

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

Expand Down Expand Up @@ -534,11 +535,11 @@ module MemoTests =

let labelAgain = find<TestLabel> 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)



Expand Down
6 changes: 5 additions & 1 deletion src/Fabulous/Memo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MemoData> =
{ Key = MemoAttributeKey
Expand Down