Skip to content

[iOS] Collapse CollectionView group headers when their content is hidden - #39533

Merged
kubaflo merged 2 commits into
dotnet:inflight/candidatefrom
carloshenriquecarniatto:fix/30924-group-header-resize
Oct 23, 2026
Merged

kubaflo merged 2 commits into
dotnet:inflight/candidatefrom
carloshenriquecarniatto:fix/30924-group-header-resize

Conversation

@carloshenriquecarniatto

@carloshenriquecarniatto carloshenriquecarniatto commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description of Change

Group headers and footers are supplementary views: their size comes from the layout, not from the visible item cells. When the content of a group header was collapsed (IsVisible = false) or its HeightRequest changed after the header had been rendered, StructuredItemsViewController2.InvalidateLayoutIfItemsMeasureChanged only checked supplementary views when ItemsView.Header/HeaderTemplate (or the footer equivalents) were set. A measure invalidation coming from GroupHeaderTemplate/GroupFooterTemplate was therefore ignored and the old header height stayed on screen.

On top of that, measuring a collapsed header still reports the content size — visibility is not part of a measure pass — so even an invalidated layout would keep the previous height.

This change, scoped to the Items2 handler (CV2):

  • checks every visible supplementary header/footer for an invalidated measure, instead of only the ItemsView.Header/Footer ones;
  • collapses the growing dimension (height for vertical lists, width for horizontal) of a header/footer whose virtual view is Collapsed.

The whole layout is still invalidated instead of single supplementary elements, to avoid the cell collapsing issue described in #25362.

The legacy Items handler (CV1) is intentionally not touched.

Before After
header content hidden, space remains header content hidden, space collapses

The header gets its original height back when its content is made visible again.

Issues Fixed

Contributes to #30924 (iOS/Mac Catalyst only).

Testing

  • Reproduced with the public repro from the issue (Axemasta/MauiRepros, GroupHeaderResizingRepro) on an iOS simulator: hiding the header now collapses its space, and showing it again restores the original height.
  • Added Issue30924 HostApp page and UI test. The page instantiates CollectionView2 so the test always runs against the supported handler, independently of the UI test configuration, and asserts that hiding the header collapses its space.
  • Controls.TestCases.HostApp builds for net10.0-ios with this change.
  • Android was checked with the same repro and is unchanged: the header still keeps its space when hidden, because RecyclerView uses a different measurement path. Windows was not available on this machine. Both need a follow-up; the issue should stay open for them.

<!-- 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 -->

Remove the unused SDK insertion templates instead of migrating their
retired `VSEngSS-MicroBuild2022-1ES` pool:

- `eng/pipelines/common/insertion.yml`
- `eng/pipelines/common/sdk-insertion.yml`

The stage template has no callers, and the job template is referenced
only by that stage. The former `maui-release.yml` caller was removed in
dotnet#31130. The current official build uses Arcade publishing; its
configured YAML entry point and matching `main` revision were checked in
Azure DevOps. The legacy DevDiv MAUI pipeline definitions are disabled.
No active pipeline, publishing stage, or pool is changed.

**Validation:** `git diff --check` passed. PyYAML parsed all 39
remaining pipeline YAML files, and all 113 static local template
references resolved. A tracked-file search found no remaining references
to the retired pool, either deleted template, or the old `sdk_insertion`
stage. No new pipeline tests were added, and no device/UI tests were run
for this configuration-only deletion.

### 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 dotnet#39518

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2f892844-9872-4d2f-8799-c45663efc2a3
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39533

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39533"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 21, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@carloshenriquecarniatto! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @carloshenriquecarniatto! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@carloshenriquecarniatto

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@github-actions github-actions Bot added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/ios labels Oct 21, 2026
@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 21, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@carloshenriquecarniatto

Copy link
Copy Markdown
Contributor Author

Thanks for the analysis — that failure comes from the legacy CollectionView1 configuration of the UI tests (TEST_CONFIGURATION_ARGS), not from the default handler. The first revision only changed Items2, so in that shard CollectionView is mapped to CollectionViewHandler (CV1) and the header still kept its height.

I pushed an update with the equivalent fix for the legacy Items handler:

  • ItemsViewController now checks the visible supplementary views for an invalidated measure (and consumes it) before invalidating the layout;
  • VerticalSupplementaryView and HorizontalSupplementaryView return a zero height/width when the bound view is Collapsed.

Validated locally on both handlers with the repro from the issue (iOS 26.2 simulator): the hidden header collapses with CV1 and with CV2.

The UI test now asserts only the collapse direction, so it runs in both configurations. Restoring the height when the header is shown again still works on CV2, but not on CV1: a zero-height supplementary view is no longer re-measured there, which is pre-existing and tracked as a follow-up rather than part of this fix.

@carloshenriquecarniatto

Copy link
Copy Markdown
Contributor Author

The update is pushed (768b1747). The Azure pipelines have not picked it up yet — external contributors cannot trigger them, so the UI tests still point at the previous commit. Could someone run /azp run when convenient?

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

2 similar comments
@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Oct 22, 2026
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@carloshenriquecarniatto — test-failure analysis for commit 768b174.

Scope CI failures Commit 768b174


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Fix CV1 restoration expectation; inspect Android crash/WebView initialization; reproduce InputTransparent failures against target.

Maintainers: comment /review tests to refresh this report.

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you remove changes from cv1 - we no longer support it

Group headers and footers are supplementary views, so their size comes from the layout instead of the visible item cells. InvalidateLayoutIfItemsMeasureChanged only looked at supplementary views when ItemsView.Header/Footer were set, which meant a measure invalidation coming from a GroupHeaderTemplate or GroupFooterTemplate never invalidated the layout. On top of that, measuring a collapsed header still reports the content size, so the layout kept the old height.

Check every visible supplementary view for an invalidated measure, and collapse the growing dimension (height for vertical lists, width for horizontal) of a header or footer whose virtual view is Collapsed. The whole layout is still invalidated instead of single supplementary elements, to avoid the cell collapse from dotnet#25362.

Contributes to dotnet#30924 (iOS/Mac Catalyst; Android and Windows use a different measurement path).
@carloshenriquecarniatto
carloshenriquecarniatto force-pushed the fix/30924-group-header-resize branch from 768b174 to 3c7561d Compare October 22, 2026 20:21
@carloshenriquecarniatto

Copy link
Copy Markdown
Contributor Author

@kubaflo Done — the cv1 changes are gone. The fix now lives only in the Items2 handler (StructuredItemsViewController2.cs + TemplatedCell2.cs), and nothing under src/Controls/src/Core/Handlers/Items/ is touched anymore.

One detail worth flagging: Issue30924 also runs in the ios_ui_tests_mono_cv1 stage, which swaps the handler globally through TEST_CONFIGURATION_ARGS=CollectionView1. So the HostApp page now instantiates CollectionView2, which keeps the test on the supported handler in every configuration (same approach as Issue30953 / Issue35859).

The PR is down to 4 files. I amended the commit, so the branch was force-pushed (768b174 → 3c7561d).

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo changed the base branch from main to inflight/candidate October 23, 2026 22:35
@kubaflo
kubaflo merged commit f898f7e into dotnet:inflight/candidate Oct 23, 2026
195 of 203 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR13 milestone Oct 23, 2026
kubaflo added a commit that referenced this pull request Oct 25, 2026
…den (#39533)

### Description of Change

Group headers and footers are supplementary views: their size comes from
the layout, not from the visible item cells. When the content of a group
header was collapsed (`IsVisible = false`) or its `HeightRequest`
changed after the header had been rendered,
`StructuredItemsViewController2.InvalidateLayoutIfItemsMeasureChanged`
only checked supplementary views when
`ItemsView.Header`/`HeaderTemplate` (or the footer equivalents) were
set. A measure invalidation coming from
`GroupHeaderTemplate`/`GroupFooterTemplate` was therefore ignored and
the old header height stayed on screen.

On top of that, measuring a collapsed header still reports the content
size — visibility is not part of a measure pass — so even an invalidated
layout would keep the previous height.

This change, scoped to the `Items2` handler (CV2):

- checks every visible supplementary header/footer for an invalidated
measure, instead of only the `ItemsView.Header`/`Footer` ones;
- collapses the growing dimension (height for vertical lists, width for
horizontal) of a header/footer whose virtual view is `Collapsed`.

The whole layout is still invalidated instead of single supplementary
elements, to avoid the cell collapsing issue described in #25362.

The legacy `Items` handler (CV1) is intentionally not touched.

| Before | After |
| --- | --- |
| header content hidden, space remains | header content hidden, space
collapses |

The header gets its original height back when its content is made
visible again.

### Issues Fixed

Contributes to #30924 (iOS/Mac Catalyst only).

### Testing

- Reproduced with the public repro from the issue
(`Axemasta/MauiRepros`, `GroupHeaderResizingRepro`) on an iOS simulator:
hiding the header now collapses its space, and showing it again restores
the original height.
- Added `Issue30924` HostApp page and UI test. The page instantiates
`CollectionView2` so the test always runs against the supported handler,
independently of the UI test configuration, and asserts that hiding the
header collapses its space.
- `Controls.TestCases.HostApp` builds for `net10.0-ios` with this
change.
- Android was checked with the same repro and is unchanged: the header
still keeps its space when hidden, because RecyclerView uses a different
measurement path. Windows was not available on this machine. Both need a
follow-up; the issue should stay open for them.

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 26, 2026
…den (#39533)

### Description of Change

Group headers and footers are supplementary views: their size comes from
the layout, not from the visible item cells. When the content of a group
header was collapsed (`IsVisible = false`) or its `HeightRequest`
changed after the header had been rendered,
`StructuredItemsViewController2.InvalidateLayoutIfItemsMeasureChanged`
only checked supplementary views when
`ItemsView.Header`/`HeaderTemplate` (or the footer equivalents) were
set. A measure invalidation coming from
`GroupHeaderTemplate`/`GroupFooterTemplate` was therefore ignored and
the old header height stayed on screen.

On top of that, measuring a collapsed header still reports the content
size — visibility is not part of a measure pass — so even an invalidated
layout would keep the previous height.

This change, scoped to the `Items2` handler (CV2):

- checks every visible supplementary header/footer for an invalidated
measure, instead of only the `ItemsView.Header`/`Footer` ones;
- collapses the growing dimension (height for vertical lists, width for
horizontal) of a header/footer whose virtual view is `Collapsed`.

The whole layout is still invalidated instead of single supplementary
elements, to avoid the cell collapsing issue described in #25362.

The legacy `Items` handler (CV1) is intentionally not touched.

| Before | After |
| --- | --- |
| header content hidden, space remains | header content hidden, space
collapses |

The header gets its original height back when its content is made
visible again.

### Issues Fixed

Contributes to #30924 (iOS/Mac Catalyst only).

### Testing

- Reproduced with the public repro from the issue
(`Axemasta/MauiRepros`, `GroupHeaderResizingRepro`) on an iOS simulator:
hiding the header now collapses its space, and showing it again restores
the original height.
- Added `Issue30924` HostApp page and UI test. The page instantiates
`CollectionView2` so the test always runs against the supported handler,
independently of the UI test configuration, and asserts that hiding the
header collapses its space.
- `Controls.TestCases.HostApp` builds for `net10.0-ios` with this
change.
- Android was checked with the same repro and is unchanged: the header
still keeps its space when hidden, because RecyclerView uses a different
measurement path. Windows was not available on this machine. Both need a
follow-up; the issue should stay open for them.

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
…den (#39533)

### Description of Change

Group headers and footers are supplementary views: their size comes from
the layout, not from the visible item cells. When the content of a group
header was collapsed (`IsVisible = false`) or its `HeightRequest`
changed after the header had been rendered,
`StructuredItemsViewController2.InvalidateLayoutIfItemsMeasureChanged`
only checked supplementary views when
`ItemsView.Header`/`HeaderTemplate` (or the footer equivalents) were
set. A measure invalidation coming from
`GroupHeaderTemplate`/`GroupFooterTemplate` was therefore ignored and
the old header height stayed on screen.

On top of that, measuring a collapsed header still reports the content
size — visibility is not part of a measure pass — so even an invalidated
layout would keep the previous height.

This change, scoped to the `Items2` handler (CV2):

- checks every visible supplementary header/footer for an invalidated
measure, instead of only the `ItemsView.Header`/`Footer` ones;
- collapses the growing dimension (height for vertical lists, width for
horizontal) of a header/footer whose virtual view is `Collapsed`.

The whole layout is still invalidated instead of single supplementary
elements, to avoid the cell collapsing issue described in #25362.

The legacy `Items` handler (CV1) is intentionally not touched.

| Before | After |
| --- | --- |
| header content hidden, space remains | header content hidden, space
collapses |

The header gets its original height back when its content is made
visible again.

### Issues Fixed

Contributes to #30924 (iOS/Mac Catalyst only).

### Testing

- Reproduced with the public repro from the issue
(`Axemasta/MauiRepros`, `GroupHeaderResizingRepro`) on an iOS simulator:
hiding the header now collapses its space, and showing it again restores
the original height.
- Added `Issue30924` HostApp page and UI test. The page instantiates
`CollectionView2` so the test always runs against the supported handler,
independently of the UI test configuration, and asserts that hiding the
header collapses its space.
- `Controls.TestCases.HostApp` builds for `net10.0-ios` with this
change.
- Android was checked with the same repro and is unchanged: the header
still keeps its space when hidden, because RecyclerView uses a different
measurement path. Windows was not available on this machine. Both need a
follow-up; the issue should stay open for them.

---------

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 23, 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 platform/ios s/agent-review-in-progress AI review is currently running for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants