Skip to content

[iOS] Fixed the Items not displayed properly in CarouselView2#31336

Merged
PureWeen merged 7 commits intodotnet:inflight/currentfrom
Ahamed-Ali:fix-31148
Dec 30, 2025
Merged

[iOS] Fixed the Items not displayed properly in CarouselView2#31336
PureWeen merged 7 commits intodotnet:inflight/currentfrom
Ahamed-Ali:fix-31148

Conversation

@Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented Aug 26, 2025

Root Cause of the issue

  • The CollectionViewUpdated method in CarouselViewController2 is not called when the ItemsSource is updated from another page, because CollectionViewUpdated is null at the time of invocation. When navigating away from the page, the event handler is unsubscribed, leaving it null. As a result, the replaced items were not reflected.

Description of Change

  • When the ItemsSource is updated on another page and navigate back to the page containing the CarouselView, refresh the currently visible items in AttachingToWindow so they are properly updated.

Issues Fixed

Fixes #31148

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
Cv2Issue.mov
CV2Fixed.mov

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Aug 26, 2025
@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Aug 26, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review August 28, 2025 13:18
Copilot AI review requested due to automatic review settings August 28, 2025 13:18
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner August 28, 2025 13:18
Copy link
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 fixes an issue where CarouselView2 items on iOS were not displaying updated content when the ItemsSource was modified from another page during navigation. The root cause was that the CollectionViewUpdated event handler was being unsubscribed when navigating away, leaving updates unhandled.

  • Adds a mechanism to track when the view was detached from the window
  • Refreshes visible items when re-attaching to the window after navigation
  • Includes comprehensive UI tests to validate the fix across platforms

Reviewed Changes

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

File Description
src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs Core fix: adds tracking for detachment state and refreshes visible items on re-attachment
src/Controls/tests/TestCases.HostApp/Issues/Issue31148.cs UI test page implementing navigation scenario with ItemsSource updates
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31148.cs NUnit test case validating the CarouselView update behavior

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen added this to the .NET 10 SR1 milestone Oct 8, 2025
@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Oct 10, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Oct 10, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Oct 23, 2025
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! The fix looks good overall and correctly addresses the root cause. However, there are a few small issues that need to be addressed:

  1. Unnecessary array copy (lines 158-160): The defensive copy of indexPaths is redundant since the ObjC binding already creates a managed copy via CFArray.ArrayFromHandle<NSIndexPath>(). This adds
    unnecessary memory allocation without providing the protection the comment suggests.

  2. Missing execution order comment: Please add a comment explaining why RefreshVisibleItems() must be called BEFORE Setup(ItemsView) in the AttachingToWindow() method. This is critical for future
    maintainability.

  3. Comment spacing: Minor - add a space after // on line 154 for consistency with the rest of the codebase.

Could you please address these issues? The logic is sound, just needs these small cleanup items before merging.

@mattleibow mattleibow force-pushed the fix-31148 branch 2 times, most recently from f08e6bb to ce8f7d5 Compare November 6, 2025 12:29
@mattleibow mattleibow dismissed jsuarezruiz’s stale review November 6, 2025 12:34

comments addressed

evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Jan 16, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [Microsoft.Maui.Controls](https://github.com/dotnet/maui) | nuget | patch | `10.0.20` -> `10.0.30` |

---

### Release Notes

<details>
<summary>dotnet/maui (Microsoft.Maui.Controls)</summary>

### [`v10.0.30`](https://github.com/dotnet/maui/releases/tag/10.0.30): SR3

[Compare Source](dotnet/maui@10.0.20...10.0.30)

#### What's Changed

.NET MAUI 10.0.30 introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 106 commits with various improvements, bug fixes, and enhancements.

#### .NET 10 Features

-   \[net10.0] Merge main to net10.0 by [@&#8203;PureWeen](https://github.com/PureWeen) in dotnet/maui#33323

#### CollectionView

-   Fixed the NRE in CarouselViewController on iOS 15.5 & 16.4  by [@&#8203;Ahamed-Ali](https://github.com/Ahamed-Ali) in dotnet/maui#30838

    <details>
    <summary>🔧 Fixes</summary>

    -   [NRE in CarouselViewController on iOS 15.5 & 16.4](dotnet/maui#28557)

    </details>

-   \[iOS, macOS] Fixed CollectionView group header size changes with ItemSizingStrategy by [@&#8203;NanthiniMahalingam](https://github.com/NanthiniMahalingam) in dotnet/maui#33161

    <details>
    <summary>🔧 Fixes</summary>

    -   [\[NET 10\] I6\_Grouping - Grouping_with_variable_sized_items changing the 'ItemSizingStrategy' also changes the header size.](dotnet/maui#33130)

    </details>

-   \[iOS]\[CV2] Fix page can be dragged down, and it would cause an extra space between Header and EmptyView text by [@&#8203;devanathan-vaithiyanathan](https://github.com/devanathan-vaithiyanathan) in dotnet/maui#31840

    <details>
    <summary>🔧 Fixes</summary>

    -   [I8\_Header_and_Footer_Null - The page can be dragged down, and it would cause an extra space between Header and EmptyView text.](dotnet/maui#31465)

    </details>

-   \[iOS] Fixed the Items not displayed properly in CarouselView2 by [@&#8203;Ahamed-Ali](https://github.com/Ahamed-Ali) in dotnet/maui#31336

    <details>
    <summary>🔧 Fixes</summary>

    -   [\[iOS\] Items are not updated properly in CarouselView2.](dotnet/maui#31148)

    </details>

#### Docs

-   Add comprehensive README to Microsoft.Maui.Controls NuGet package by [@&#8203;jfversluis](https://github.com/jfversluis) via [@&#8203;Copilot](https://github.com/Copilot) in dotnet/maui#32835

    <details>
    <summary>🔧 Fixes</summary>

    -   [Improve the MAUI Nuget readme.md file](dotnet/maui#31969)

    </details>

-   Improve Controls Core API docs 2 by [@&#8203;jfversluis](https://github.com/jfversluis) in https://github.com/dotnet...
This was referenced Jan 19, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution p/0 Current heighest priority issues that we are targeting for a release. partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[iOS] Items are not updated properly in CarouselView2.

8 participants