Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a Border.TranslationY does not work in Android - fix #25760

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25747.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue25747">
<Grid RowDefinitions="*,Auto">
<Border Background="Green"
HeightRequest="100"
WidthRequest="100">
<Label TextColor="Black"
Text="This label should not be visible on the screenshot"/>
</Border>

<Border Background="Red"
x:Name="Border"
HeightRequest="100"
WidthRequest="100"/>
<Button Grid.Row="1"
AutomationId="Button"
Text="Translate border"
Clicked="Button_Clicked"/>
</Grid>
</ContentPage>
19 changes: 19 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25747.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 25747, "Updating a Border.TranslationY does not work", PlatformAffected.Android)]

public partial class Issue25747 : ContentPage
{
public Issue25747()
{
InitializeComponent();
}

bool _goDown = true;
void Button_Clicked(object sender, EventArgs e)
{
Border.TranslationY = _goDown ? 100 : 0;
_goDown = !_goDown;
Border.InputTransparent = !Border.InputTransparent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue25747 : _IssuesUITest
{
public Issue25747(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Updating a Border.TranslationY does not work";

[Test]
[Category(UITestCategories.Border)]
[Category(UITestCategories.InputTransparent)]
public void TranslationYShouldWork()
{
App.WaitForElement("Button");
App.Click("Button");
App.Click("Button");

VerifyScreenshot();
kubaflo marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions src/Core/src/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ internal static bool NeedsContainer(this IView? view)
return true;
#endif

#if ANDROID || IOS
#pragma warning disable CS0618 // Type or member is obsolete
if (view is IBorder border && border.Border != null)
return true;
#pragma warning restore CS0618 // Type or member is obsolete
#elif WINDOWS
#if WINDOWS || ANDROID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UITest CollectionViewMeasureFirstItem is failing on Android after the changes. The snapshot have small differences. The sample use a CV with Borders in the DataTemplate, could you take a look?
Let me know if can help.

if (view is IBorderView border)
return border?.Shape != null || border?.Stroke != null;
#endif
Expand Down
Loading