Stop iOS SetNeedsLayout propagation by looking at VisualElement computed Constraint#28479
Merged
rmarinho merged 4 commits intodotnet:mainfrom Apr 14, 2025
Merged
Conversation
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. |
5c5021c to
d870612
Compare
This was referenced Apr 9, 2025
rmarinho
approved these changes
Apr 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
#26629 removed
SetNeedsLayoutpropagation 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).MauiViewnow looks at the computedinternal 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 }.Pagenow implements that interface with a fixed=> trueso I've been able to remove the hardcoded stop propagation logicif (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.SelfConstrainttoFixed = 3on a node to stop the propagation.That said this automatically solves use cases where the user is setting
WidthRequestandHeightRequestto a fixed value.Issues Fixed
Fixes #28410