Skip to content

MauiScrollView resets ContentOffset on first layout pass in 9.0.80 #30147

Closed
@mjo151

Description

@mjo151

Description

#29469 made a change to the MauiScrollView on iOS that results in the X ContentOffset being set to zero the first time LayoutSubviews is called when the layout orientation is Left-to-Right. It looks like a subsequent PR (#29735) tried to address some issues caused by the first PR by fixing the Y ContentOffset, but the X ContentOffset still gets reset to 0.

I have a custom view that uses the MauiScrollView for horizontal scrolling, and this change causes issues when I try to set an initial X Scroll value.

I am not sure of the reason for setting the ContentOffset when the layout is Left-To-Right. If it must be reset, then _previousEffectiveUserInterfaceLayoutDirection should probably be initialized to EffectiveUserInterfaceLayoutDirection when MauiScrollView is created (before LayoutSubviews is called).

Steps to Reproduce

If you look at MauiScrollView.LayoutSubviews, you can see that _previousEffectiveUserInterfaceLayoutDirection is not initialized, resulting in ContentOffset being reset the first time LayoutSubviews is called.

Link to public reproduction project repository

No response

Version with bug

9.0.80 SR8

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.70 SR7

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions