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
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