Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] CollectionView as root element in ContentPage makes top item sticky #27611

Open
drasticactions opened this issue Feb 6, 2025 · 5 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView area-controls-label Label, Span area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@drasticactions
Copy link
Contributor

Description

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-06.at.23.11.54.mp4

Image

If you have a CollectionView as the root element on a page, and it has a DataTemplate that is nested in a another type like Grid or StackLayout, the top most cells contents will stay sticky at the top of the view when scrolling instead of going off screen.

If the Page is wrapped in another view (NavigationView, Shell), it doesn't happen.

I tried with CollectionViewHandler2 and it did the same thing.

I could not get it to reproduce in Catalyst.

It did work in iOS with .NET 8.

Steps to Reproduce

Run the sample

Link to public reproduction project repository

https://github.com/drasticactions/MauiRepoRedux/tree/collectionview-break

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.100 SR10

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

Wrap the page in a NavigationPage or use Shell

Relevant log output

@drasticactions drasticactions added the t/bug Something isn't working label Feb 6, 2025
@kubaflo kubaflo assigned kubaflo and unassigned kubaflo Feb 7, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Feb 7, 2025

Hi! @drasticactions, I think the issue should be fixed when you add IgnoreSafeArea="True".

<CollectionView ItemsSource="{x:Static local:NamedColor.All}">
                <CollectionView.ItemTemplate>
                        <DataTemplate x:DataType="local:NamedColor">
                                <VerticalStackLayout IgnoreSafeArea="True">
                                        <Label Text="{Binding FriendlyName}"/>
                                </VerticalStackLayout>
                        </DataTemplate>
                </CollectionView.ItemTemplate>
</CollectionView>

If you want to use a safe area then add the lines below to your page

xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.UseSafeArea="True"

I am only wondering if this is a bug or not. @PureWeen @rmarinho thoughts?

@kubaflo kubaflo added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 labels Feb 7, 2025
@kubaflo kubaflo self-assigned this Feb 7, 2025
@jsuarezruiz jsuarezruiz added the area-controls-label Label, Span label Feb 7, 2025
@jsuarezruiz
Copy link
Contributor

Happens with CollectionViewHandler2?

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Feb 7, 2025
@jsuarezruiz jsuarezruiz added this to the .NET 9 Servicing milestone Feb 7, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Feb 7, 2025

Happens with CollectionViewHandler2?

It does

@kubaflo kubaflo removed their assignment Feb 7, 2025
@kubaflo
Copy link
Contributor

kubaflo commented Feb 7, 2025

The issue seems to arise because we are not using Shell or NavigationPage/TabbedPage. As a result, all elements that inherit from Layout implicitly respect the safe area insets, sometimes leading to unexpected behavior.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Maui.Controls.Sample.MainPage"
             xmlns:local="clr-namespace:Maui.Controls.Sample">
             <Grid>
                <Label Text="Hello"/>
             </Grid>
</ContentPage>

@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Feb 8, 2025
@RoiChen001
Copy link

I can repro this issue at iOS platform on the latest 17.13.0 Preview 5.0(9.0.30 & 9.0.0 &8.0.100).
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView area-controls-label Label, Span area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants