Stop iOS SetNeedsLayout propagation by looking at VisualElement computed Constraint #28479
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
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 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 }
.Page
now implements that interface with a fixed=> true
so 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.SelfConstraint
toFixed = 3
on a node to stop the propagation.That said this automatically solves use cases where the user is setting
WidthRequest
andHeightRequest
to a fixed value.Issues Fixed
Fixes #28410