Skip to content

Fix duplicate state container view states#3095

Merged
TheCodeTraveler merged 11 commits intomainfrom
Fix-Duplicate-StateContainer-ViewStates
Feb 14, 2026
Merged

Fix duplicate state container view states#3095
TheCodeTraveler merged 11 commits intomainfrom
Fix-Duplicate-StateContainer-ViewStates

Conversation

@TheCodeTraveler
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler commented Feb 13, 2026

Description of Change

This PR removes the public static IList<View> that was being used for the DefaultValueCreator of the StateContainer.StateViews Attached Property, replacing it with a simple instance of a new collection, [].

This fixes a bug where, where this static IList<View> was being reused for every StateView for every StateContainer.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

Additional information

bijington
bijington previously approved these changes Feb 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a StateContainer bug where the default StateViews collection was shared across layouts, causing state views to bleed between different StateContainer usages (issue #3068).

Changes:

  • Removed the static default StateViews collection from StateContainerDefaults.
  • Updated the StateViews attached property default value creator to return a new empty collection per layout.
  • Adjusted StateContainerController initialization and updated unit tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/CommunityToolkit.Maui/Primitives/StateContainerDefaults.shared.cs Removes the shared static default StateViews collection.
src/CommunityToolkit.Maui/Layouts/StateContainer/StateContainerController.shared.cs Refactors controller construction and changes StateViews to IReadOnlyList with init.
src/CommunityToolkit.Maui/Layouts/StateContainer/StateContainer.shared.cs Uses a new empty collection as the default StateViews value; controller creation now copies StateViews.
src/CommunityToolkit.Maui.UnitTests/Layouts/StateContainerTests.cs Updates tests for the new StateViews behavior and adds a new uniqueness test.

TheCodeTraveler and others added 3 commits February 13, 2026 15:10
…r.shared.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rController.shared.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

…s.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 13, 2026 23:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

…s.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 13, 2026 23:30
…rController.shared.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TheCodeTraveler
Copy link
Copy Markdown
Collaborator Author

Thanks @bijington! Could you give it one more quick review now that I implemented some of CoPilot's suggestions?

@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) February 13, 2026 23:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

@bijington bijington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TheCodeTraveler TheCodeTraveler merged commit 251d61a into main Feb 14, 2026
10 checks passed
@TheCodeTraveler TheCodeTraveler deleted the Fix-Duplicate-StateContainer-ViewStates branch February 14, 2026 08:33
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] StateContainer broken / same view is displayed all the time on Version 14.0.0

3 participants