Skip to content

Commit

Permalink
Fixed an issue where a modifier applied on a Component itself would n…
Browse files Browse the repository at this point in the history
…ot be applied correctly
  • Loading branch information
TimLariviere committed Oct 28, 2024
1 parent 29cd1a0 commit 5fcd382
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/Fabulous/Component.fs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ type ComponentBody = delegate of ComponentContext -> struct (ComponentContext *
[<Struct; NoEquality; NoComparison>]
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<_>
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Fabulous/MvuComponent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5fcd382

Please sign in to comment.