-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
87df635
Fix #22289
kubaflo 485c641
Added a UI Test (#22289)
kubaflo c509ac5
Update LabelHandler.Windows.cs
PureWeen f24fc87
Update ViewHandler.cs
PureWeen 72198ab
Update Issue22289.cs
kubaflo df2e5f7
Update ViewHandler.cs
kubaflo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Controls/tests/TestCases.HostApp/Issues/Issue22289.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
21 changes: 21 additions & 0 deletions
21
src/Controls/tests/TestCases.HostApp/Issues/Issue22289.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22289.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.TestCases.Tests.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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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 wonder if this should be a command? We can keep it "internal" for now, but just a command that is triggered when the container view changes? I think there are a few places that this is important to track:
Just looking at the Core layer in my PR: https://github.com/dotnet/maui/pull/13114/files#diff-e802e21561b0e99ffbb055b9ea43d833899fc9f06d91a64c5a9067c9427b7bcc there are several things I was adding to the
ContainerAffectingProperties
:IView.Background
,ILabel.VerticalTextAlignment
,IView.Visibility
,IView.Opacity
,IView.Clip
,IView.Shadow
,IBorder.Border
,IView.InputTransparent
. Basically, anything that would trigger a container view also needs to be re-triggered when the container view changes.Just like you are fixing here, if the opacity changes, we need to trigger some logic so opacity can be correctly mapped to the correct view if the visibility happens and secretly adds a container. And the same is true if you add a container because of the opacity, the visibility of both the container and platform view is managed.
I think what you have here is much better than my PR - no need to collect everything in a list - but if the command fires, each handler can control what it does when the container changes.
@PureWeen not sure if this is just abusing the system even more and we really should just do it right with a method? Maybe the view handler can get an internal
OnContainerViewChanged(PlatformView oldValue, PlatformView newValue)
?All we need is a way for a handler to decide to re-fire mappers if the container changes. Commands are nice as they can be extended via third parties without having to derive from the existing handler. But, will anyone ever extend the mappers? Maybe we can have an internal virtual for now and think about it some more and maybe move to a command later?
I don't think this PR should fix everything, I would really want to add the tests for that. But if this PR can setup the base/correct/current plan for doing this with the container view, then we can add new PRs to fix things.