Repository navigation
[iOS/Mac][Revert] CollectionView2 height-update fix (#38441) - #39856
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39856Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39856" |
This comment has been minimized.
This comment has been minimized.
|
Hey there @@SyedAbdulAzeemSF4852! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🔵 Needs a closer look
Human validation on iOS/MacCatalyst is needed to weigh the nested-scrolling fix against the restored height-update limitation and shared-controller impact, especially with the original transition tests removed.
No open issues 🎉
What changed in this PR
Reverts #38441 in the iOS/MacCatalyst CollectionView2 handler to address the nested-scrolling regression reported in #39847, where a CollectionView inside a ScrollView displays a second vertical scrollbar.
Changes:
- Restores content-size checking to
ViewWillLayoutSubviews()and removes theViewDidLayoutSubviews()override. - Removes the corresponding iOS and MacCatalyst API entries.
- Deletes the two test pages and two UI test files introduced by the reverted change.
| File | Description |
|---|---|
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue38276.cs |
Removes height-update and empty-transition UI tests. |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue38276_Grouped.cs |
Removes grouped height-update UI test. |
src/Controls/tests/TestCases.HostApp/Issues/Issue38276.cs |
Removes the ungrouped height-update test page. |
src/Controls/tests/TestCases.HostApp/Issues/Issue38276_Grouped.cs |
Removes the grouped height-update test page. |
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt |
Removes the MacCatalyst override API entry. |
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt |
Removes the iOS override API entry. |
src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs |
Restores pre-layout content-size checking. |
Review effort: Balanced
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
…ed scrolling (#39882) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Fix CollectionView height updates after replacing ItemsSource with fewer items on iOS and Mac Catalyst, while preserving sizing behavior when CollectionView is nested inside ScrollView. In #38276, CollectionView retains its previously rendered height after the item count decreases, leaving unused space and stale Height/SizeChanged values. The previous fix, #38441, moved content-size checking exclusively to ViewDidLayoutSubviews. This introduced the nested-scroll regression reported in #39847: the CollectionView could remain smaller than its content, creating an additional vertical scroll range inside the outer ScrollView. That fix was reverted by #39856. This replacement builds on the reverted implementation: - Preserve the existing ViewWillLayoutSubviews content-size check. - Add a guarded ViewDidLayoutSubviews check to detect self-sizing content changes resolved during native layout, allowing the CollectionView to shrink. - Skip the post-layout check when content exceeds the current bounds in the scrolling direction, without updating the cached content size. This leaves growth detection to the pre-layout check and avoids the nested-scroll regression. - Refresh empty-source tracking when replacing ItemsSource so grouped collections collapsed to zero can grow again, even when UIKit defers data-source callbacks. - Restore the required iOS and Mac Catalyst public API entries for the layout callback override. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Fixes #38276 Related: #39847 — adds coverage to prevent reintroducing the nested-scroll regression already addressed by the revert. <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Issues Fixed
Fixes #39847
Output
Before_Output.mov
After.mov