KEMBAR78
MauiScrollView resets ContentOffset on first layout pass - fix by kubaflo · Pull Request #30453 · dotnet/maui · GitHub
Skip to content

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jul 6, 2025

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

@mjo151 could you please verify if this PR fixes your issue, since you did not provide your repro so that I can test it
https://github.com/dotnet/maui/wiki/Testing-PR-Builds

Issues Fixed

Fixes #30147

@Copilot Copilot AI review requested due to automatic review settings July 6, 2025 23:12
@kubaflo kubaflo requested a review from a team as a code owner July 6, 2025 23:12
Copy link
Contributor

@Copilot 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 prevents MauiScrollView on iOS from inadvertently resetting its scroll position on the very first layout pass by adding an explicit check against _previousEffectiveUserInterfaceLayoutDirection.

  • Introduces a guard so that on the initial layout pass (when _previousEffectiveUserInterfaceLayoutDirection is null), ContentOffset isn’t reset.
  • Ensures that on subsequent layout passes (when the layout direction is known), the old scroll offset logic still applies.
Comments suppressed due to low confidence (1)

src/Core/src/Platform/iOS/MauiScrollView.cs:67

  • Consider adding a unit test to verify that on the initial layout pass (when _previousEffectiveUserInterfaceLayoutDirection is null) the ContentOffset remains unchanged, and that on subsequent passes it resets correctly.
					else if (_previousEffectiveUserInterfaceLayoutDirection is not null)

@PureWeen
Copy link
Member

PureWeen commented Jul 6, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Jul 7, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 SR9 milestone Jul 7, 2025
@PureWeen PureWeen moved this from Todo to In Progress in MAUI SDK Ongoing Jul 7, 2025
@PureWeen PureWeen moved this from In Progress to Ready To Review in MAUI SDK Ongoing Jul 7, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Jul 8, 2025
@rmarinho
Copy link
Member

rmarinho commented Jul 8, 2025

@PureWeen do we want to backdoor this one?

@PureWeen
Copy link
Member

PureWeen commented Jul 9, 2025

  • failing tests unrelated

@PureWeen
Copy link
Member

PureWeen commented Jul 9, 2025

@PureWeen do we want to backdoor this one?

AFAICT the scenario is a bit edge case that regressed
So we'll just make sure to get it in SR9 and not risk backporting

@PureWeen PureWeen merged commit c65f433 into dotnet:main Jul 9, 2025
124 of 129 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Jul 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-scrollview ScrollView community ✨ Community Contribution

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

MauiScrollView resets ContentOffset on first layout pass in 9.0.80

5 participants