diff --git a/CHANGELOG.md b/CHANGELOG.md index faf65337f..ce9c2e519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _No unreleased changes_ +## [3.0.0-pre7] - 2024-09-28 + +### Fixed +- Fixed an issue where a modifier applied on a Component itself would not be applied correctly + ## [3.0.0-pre6] - 2024-09-24 ### Changed - Add equality constraint on 'msg to prevent confusion with new non-MVU modifiers by @TimLariviere https://github.com/fabulous-dev/Fabulous/pull/1084 -### Added -- Add new `CollectionBuilder` constructor using an `AttributesBundle` by @edgarfgp in https://github.com/fabulous-dev/Fabulous/pull/1081 - ## [3.0.0-pre5] - 2024-05-17 ### Added @@ -147,7 +149,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-pre6...HEAD +[unreleased]: https://github.com/fabulous-dev/Fabulous/compare/3.0.0-pre7...HEAD +[3.0.0-pre7]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre7 [3.0.0-pre6]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre6 [3.0.0-pre5]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre5 [3.0.0-pre4]: https://github.com/fabulous-dev/Fabulous/releases/tag/3.0.0-pre4 diff --git a/src/Fabulous/Component.fs b/src/Fabulous/Component.fs index 48ec99459..a42f87414 100644 --- a/src/Fabulous/Component.fs +++ b/src/Fabulous/Component.fs @@ -209,7 +209,7 @@ type ComponentBody = delegate of ComponentContext -> struct (ComponentContext * [] type ComponentData = { Key: string; Body: ComponentBody } -type Component(treeContext: ViewTreeContext, body: ComponentBody, context: ComponentContext) = +type Component(componentDataKey: ScalarAttributeKey, treeContext: ViewTreeContext, body: ComponentBody, context: ComponentContext) = let mutable _body = body let mutable _context = context let mutable _widget = Unchecked.defaultof<_> @@ -224,7 +224,9 @@ type Component(treeContext: ViewTreeContext, body: ComponentBody, context: Compo let componentScalars = match componentWidget.ScalarAttributes with | ValueNone -> ValueNone - | ValueSome attrs -> ValueSome(Array.skip 1 attrs) // skip the first attribute which is the component data + | ValueSome attrs -> + let filteredAttrs = attrs |> Array.filter(fun scalarAttr -> scalarAttr.Key <> componentDataKey) + ValueSome(filteredAttrs) // skip the component data let scalars = match struct (rootWidget.ScalarAttributes, componentScalars) with @@ -366,7 +368,7 @@ module Component = | None -> failwith "Component widget must have a body" let ctx = new ComponentContext() - let comp = new Component(treeContext, data.Body, ctx) + let comp = new Component(Data.Key, treeContext, data.Body, ctx) let struct (node, view) = comp.CreateView(ValueSome widget) treeContext.SetComponent comp view @@ -386,7 +388,7 @@ module Component = | None -> failwith "Component widget must have a body" let ctx = new ComponentContext() - let comp = new Component(treeContext, data.Body, ctx) + let comp = new Component(Data.Key, treeContext, data.Body, ctx) let node = comp.AttachView(widget, view) treeContext.SetComponent comp view diff --git a/src/Fabulous/MvuComponent.fs b/src/Fabulous/MvuComponent.fs index 2b66148d6..b4fd06e34 100644 --- a/src/Fabulous/MvuComponent.fs +++ b/src/Fabulous/MvuComponent.fs @@ -54,7 +54,7 @@ module MvuComponent = { treeContext with Dispatch = runner.Dispatch } - let comp = new Component(treeContext, data.Body, ctx) + let comp = new Component(Data.Key, treeContext, data.Body, ctx) let struct (node, view) = comp.CreateView(ValueSome widget) treeContext.SetComponent comp view @@ -87,7 +87,7 @@ module MvuComponent = { treeContext with Dispatch = runner.Dispatch } - let comp = new Component(treeContext, data.Body, ctx) + let comp = new Component(Data.Key, treeContext, data.Body, ctx) let node = comp.AttachView(widget, view) treeContext.SetComponent comp view