From 95d989bdf0d00b19415a16f621605d98c3a95d28 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 16 Apr 2024 14:22:58 +0100 Subject: [PATCH 1/2] Fix ScalarAttributes data key lookup --- src/Fabulous/MvuComponent.fs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Fabulous/MvuComponent.fs b/src/Fabulous/MvuComponent.fs index a54c8d741..5089159b0 100644 --- a/src/Fabulous/MvuComponent.fs +++ b/src/Fabulous/MvuComponent.fs @@ -99,12 +99,25 @@ module MvuComponent = let canReuseMvuComponent (prev: Widget) (curr: Widget) = let prevData = match prev.ScalarAttributes with - | ValueSome attrs when attrs.Length > 0 -> attrs[0].Value :?> MvuComponentData + | ValueSome attrs -> + let scalarAttrsOpt = + attrs |> Array.tryFind(fun scalarAttr -> scalarAttr.Key = Data.Key) + + match scalarAttrsOpt with + | None -> failwithf "Component widget must have a body" + | Some value -> value.Value :?> MvuComponentData + | _ -> failwith "Component widget must have a body" let currData = match curr.ScalarAttributes with - | ValueSome attrs when attrs.Length > 0 -> attrs[0].Value :?> MvuComponentData + | ValueSome attrs -> + let scalarAttrsOpt = + attrs |> Array.tryFind(fun scalarAttr -> scalarAttr.Key = Data.Key) + + match scalarAttrsOpt with + | None -> failwithf "Component widget must have a body" + | Some value -> value.Value :?> MvuComponentData | _ -> failwith "Component widget must have a body" // NOTE: Somehow using = here crashes the app and prevents debugging... From 6637de576812d00a4d2bc17b587f6061b75999bb Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 16 Apr 2024 14:28:28 +0100 Subject: [PATCH 2/2] release notes --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c28afa5..ffb2b91c7 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_ +## [3.0.0-pre4] - 2024-04-16 + +### Changed +- Find the component data key in ScalarAttributes by @edgarfgp (https://github.com/fabulous-dev/Fabulous/pull/1076) + ## [3.0.0-pre3] - 2024-04-12 ### Changed @@ -125,7 +130,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/3.0.0-pre3...HEAD +[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre4...HEAD +[3.0.0-pre4]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre4 [3.0.0-pre3]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre3 [3.0.0-pre2]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre2 [3.0.0-pre1]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre1