maui icon indicating copy to clipboard operation
maui copied to clipboard

InvalidateMeasure() does not trigger a native layout.

Open Clancey opened this issue 3 years ago • 8 comments

Description

If you call label.Handler.NativeView.InvalidateMeasure(label) it doesnt trigger a layout.

This is problematic, as we need to trigger re-layouts when font sizes change.

Steps to Reproduce

I am using comet, My View Heirarchy is VStack{ Text(), Button() } When I set the text to exact sizing, it matches the initial value. If on button click, I extend the labels text to more characters, it doesn't relayout.

I also added

LabelHandler.LabelMapper.Add(nameof(IText.Text), (h, l) => {
				h.NativeView.InvalidateMeasure(l);
				LabelHandler.MapText(h, l);
			});

to force the invalidate

Version with bug

Preview 11

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, macOS

Affected platform versions

All

Did you find any workaround?

No response

Relevant log output

No response

Clancey avatar Jan 12 '22 23:01 Clancey

Thank you so much for your bug report! Unfortunately, we cannot reproduce your issue with the information above, could you provide a sample project and screenshots or more details that we can reproduce your issue? That should greatly speed up the process, thanks!

XamlTest avatar Mar 01 '22 08:03 XamlTest

Hi @Clancey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Mar 01 '22 08:03 ghost

I'm also running into this in various areas when doing anything dynamic

J-Swift avatar Mar 16 '22 15:03 J-Swift

I got a feeling you are supposed to use some new method from IView or something... @hartez is that still something as I see a explicit implementation or did that all change?

mattleibow avatar Apr 29 '22 19:04 mattleibow

Will calling InvalidateMeasure() trigger the UnLoaded event? I write a sample project MauiApp4102.zip. Please add breakpoint in UnLoadedEvent and run the project. Then click the "Change Font Size" button.

I validated with vs main build(32507.29.main) and the UnLoaded event wasn't triggered.

VincentBu avatar May 09 '22 06:05 VincentBu

Hi @Clancey. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar May 09 '22 06:05 ghost

Will calling InvalidateMeasure() trigger the UnLoaded event?

No. InvalidateMeasure should cause the UI to be layout it's views.

mattleibow avatar May 09 '22 21:05 mattleibow

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 30 '22 15:08 ghost

Try InvalidateMeasureNonVirtual(InvalidationTrigger.HorizontalOptionsChanged); this will cause the parent view to layout and call your MeasureOverride and ArrangeOverride. Do not forget to set manually DesiredSize inside your MeasureOverride in case you do not call its base.

taublast avatar Jan 22 '23 21:01 taublast

Repro on version 17.6.0 Preview 3.0 with the above project MauiApp4102.zip. It doesn't cause the UI to be layout it's views.

jinxinjuan avatar Apr 25 '23 03:04 jinxinjuan