dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22k stars 1.72k forks source link

Updating a Border.TranslationY does not work in Android #24818

Open munkii opened 1 day ago

munkii commented 1 day ago

Description

We have a custom "BottomSheetControl" implemented in Xamarin Forms that works in both iOS and Android. We are portiung it and the rest of the App to MAUI.

I have a repro of the issue in this git repo, https://github.com/munkii/MauiAppBottomSheetIssue

The only change we have made to it is that we have swuicthed from using a Frame to a Border for the elment named "Sheet". This problem existed in MAUI even with Frame.

When the Sheet is "opened" we update the TranslationY. We were animating the value but for the sake of simplicitly during this debugging process I have switched to setting directly.

public async Task OpenSheet(double? position = null)
{
    System.Diagnostics.Debug.WriteLine("BottomSheetControl.OpenSheet " + position);

    if (position.HasValue == false)
    {
        position = 0;
    }

    ////await Task.WhenAll(
    ////    this.Backdrop.FadeTo(0.4, length: BottomSheetControl.SheetAnimationDuration),
    ////    this.Sheet.TranslateTo(0, position.Value, length: BottomSheetControl.SheetAnimationDuration, easing: Easing.SinIn));

    this.Backdrop.Opacity = 0.4;
    this.Sheet.TranslationY = position.Value;

    this.BottomSheetContentView.InputTransparent = this.Backdrop.InputTransparent = false;
}

This approach works fine on an iOS device but in Android the content that has been translated up is not visible. If you navigate to the Border via "Live Visual Tree" you can see that it's TranslateY is 0 as expected.

Screenshot_Before_PropertyEdit

If you edit the TranslateY to 1 (or any value) the content is immediatly available, if you set it back to 0 it is still fine.

Screenshot_After_PropertyEdit

It's as if the Border needs a signal to repaint

Steps to Reproduce

Using the linked repro you can see that the Label in the grid is displayed when you press "Click me" in iOS. Pressing anywhere outside of the Label will cause it to animate away.

Try the same thing in Android and the Label is not visible. Until you fiddle with the TranslateY via the Live Property explorer

Link to public reproduction project repository

https://github.com/munkii/MauiAppBottomSheetIssue

Version with bug

8.0.82 SR8.2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

github-actions[bot] commented 1 day ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 1 day ago

I can repro this issue at Android platform on the latest 17.12.0 Preview 2.0(8.0.90 & 8.0.82 & 8.0.80).