-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Android] InputTransparent="true" on a Layout breaks child controls - Fix #22345
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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.Issue22289" | ||
Title="Issue22289"> | ||
<Grid RowDefinitions="*,*,*"> | ||
<Grid InputTransparent="True" BackgroundColor="Red"> | ||
<Label Text="Grid with InputTransparent"/> | ||
<Button AutomationId="button1" x:Name="Button1" VerticalOptions="Center" Text="Click me" IsVisible="False"/> | ||
</Grid> | ||
<Grid Grid.Row="1" BackgroundColor="Green"> | ||
<Label Text="Grid without InputTransparent"/> | ||
<Button AutomationId="button2" x:Name="Button2" VerticalOptions="Center" Text="Click me" IsVisible="False"/> | ||
</Grid> | ||
<Button AutomationId="changeVisibilityButton" Grid.Row="2" Clicked="Button_Clicked" Text="Click" /> | ||
</Grid> | ||
</ContentPage> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 22289, "InputTransparent=\"true\" on a Layout breaks child controls on Android", PlatformAffected.Android)] | ||
|
||
public partial class Issue22289 : ContentPage | ||
{ | ||
public Issue22289() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void Button_Clicked(object sender, System.EventArgs e) | ||
{ | ||
Button1.IsVisible = !Button1.IsVisible; | ||
Button2.IsVisible = !Button2.IsVisible; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue22289 : _IssuesUITest | ||
{ | ||
public override string Issue => "InputTransparent=\"true\" on a Layout breaks child controls on Android"; | ||
public Issue22289(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
public void ButtonsShouldBeVisible() | ||
{ | ||
App.WaitForElement("changeVisibilityButton"); | ||
App.Click("changeVisibilityButton"); | ||
|
||
App.WaitForElement("button1"); | ||
App.WaitForElement("button2"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -417,6 +417,12 @@ public static void MapContainerView(IViewHandler handler, IView view) | |
handler.HasContainer = viewHandler.NeedsContainer; | ||
else | ||
handler.HasContainer = view.NeedsContainer(); | ||
|
||
handler.UpdateValue(nameof(IView.Visibility)); | ||
|
||
#if WINDOWS | ||
handler.UpdateValue(nameof(IView.Opacity)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know if it is just windows only? Somehow I feel opacity is such a basic feature it affects more and we just saw it with windows first. If we don't want to move the cheese to much in the PR, maybe just make this comment an issue and I can have a look when I get back to my keyboard. |
||
#endif | ||
} | ||
|
||
/// <summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to add
handler.UpdateValue(nameof(IView.Opacity))
and remove this line from LabelHandler.windows.cs
I think when "handler.UpdateValue(nameof(IViewHandler.ContainerView));" was originally added we didn't have the correct MapContainerview flow, so it made sense there
You only need to update the ContainerView if that property would result in the container getting added/removed