Skip to content

Stop iOS SetNeedsLayout propagation by looking at VisualElement computed Constraint #28479

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

Merged

Conversation

albyrock87
Copy link
Contributor

@albyrock87 albyrock87 commented Mar 18, 2025

Description of Change

#26629 removed SetNeedsLayout propagation via inheritance, this was needed to fix #24996.
Unfortunately, this also removed the ability to intercept and stop propagation as needed.

This PR enhances what we've done in the previous one by giving the stop-propagation control back to the platform view by returning a boolean on bool IPlatformMeasureInvalidationController.InvalidateMeasure(bool isPropagating).

MauiView now looks at the computed internal LayoutConstraint Constraint => ComputedConstraint | SelfConstraint; property to see whether the view has fixed constraints.
This is achieved by checking whether we're propagating and CrossPlatformLayout is IConstrainedView { HasFixedConstraints: true }.

Page now implements that interface with a fixed => true so I've been able to remove the hardcoded stop propagation logic if (superview is ContentView { IsPage: true } or UIScrollView) completely.

This fixes the attached issue because it allows (unfortunately only via reflection for now), to set VisualElement.SelfConstraint to Fixed = 3 on a node to stop the propagation.

That said this automatically solves use cases where the user is setting WidthRequest and HeightRequest to a fixed value.

Issues Fixed

Fixes #28410

@albyrock87 albyrock87 requested a review from a team as a code owner March 18, 2025 16:47
@albyrock87 albyrock87 changed the title Stop iOS SetNeedsLayout propagation by looking at VisualElement compu… Stop iOS SetNeedsLayout propagation by looking at VisualElement computed Constraint Mar 18, 2025
@albyrock87 albyrock87 marked this pull request as draft March 18, 2025 16:48
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Mar 18, 2025
Copy link
Contributor

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

@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/ios labels Mar 19, 2025
@albyrock87 albyrock87 force-pushed the stop-propagation-by-fixed-constraints branch from 5c5021c to d870612 Compare March 31, 2025 14:40
@albyrock87 albyrock87 marked this pull request as ready for review March 31, 2025 23:18
@dotnet dotnet deleted a comment from azure-pipelines bot Apr 8, 2025
@dotnet dotnet deleted a comment from PureWeen Apr 8, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Apr 11, 2025
@dotnet dotnet deleted a comment from PureWeen Apr 11, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Apr 11, 2025
@dotnet dotnet deleted a comment from PureWeen Apr 11, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Apr 11, 2025
@dotnet dotnet deleted a comment from jsuarezruiz Apr 11, 2025
@rmarinho rmarinho added this to the .NET 9 SR7 milestone Apr 11, 2025
@rmarinho rmarinho merged commit d6d8223 into dotnet:main Apr 14, 2025
128 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter community ✨ Community Contribution platform/ios
Projects
None yet
3 participants