-
Notifications
You must be signed in to change notification settings - Fork 2k
[Windows] - Fix InputTransparent layouts losing background color visibility #30311
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
Changes from 7 commits
8ec56ad
13e12a8
db4682c
0ae318b
bf7f944
988789a
690ad4a
05ecc45
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,147 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 17389, "InputTransparent should not affect background color on Windows layouts", PlatformAffected.UWP)] | ||
| public class Issue17389 : TestContentPage | ||
| { | ||
| Grid redGrid; | ||
| Grid greenGrid; | ||
| Border blueBorder; | ||
| ContentView purpleContent; | ||
| Label tapCountLabel; | ||
| Label redGridLabel; | ||
| Label greenGridLabel; | ||
| Label blueBorderLabel; | ||
| Label purpleContentLabel; | ||
| int tapCount; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| tapCountLabel = new Label { Text = "Tap count: 0", HorizontalOptions = LayoutOptions.Center }; | ||
|
|
||
| redGrid = CreateBackgroundTestGrid(Colors.Red, false, "RedGrid", out redGridLabel); | ||
| greenGrid = CreateBackgroundTestGrid(Colors.Green, false, "GreenGrid", out greenGridLabel); | ||
|
|
||
| blueBorderLabel = new Label { Text = "Blue Border (InputTransparent=False)", HorizontalOptions = LayoutOptions.Center, AutomationId = "BlueBorder" }; | ||
| blueBorder = new Border | ||
| { | ||
| BackgroundColor = Colors.Blue, | ||
| InputTransparent = false, | ||
| WidthRequest = 200, | ||
| HeightRequest = 100, | ||
| Content = blueBorderLabel | ||
| }; | ||
| AddTapGesture(blueBorder); | ||
|
|
||
| purpleContentLabel = new Label { Text = "Purple Content (InputTransparent=False)", AutomationId = "PurpleContent" }; | ||
| purpleContent = new ContentView | ||
| { | ||
| BackgroundColor = Colors.Purple, | ||
| InputTransparent = false, | ||
| WidthRequest = 200, | ||
| HeightRequest = 100, | ||
| Content = purpleContentLabel | ||
| }; | ||
| AddTapGesture(purpleContent); | ||
|
|
||
| Content = CreateMainContent(); | ||
| } | ||
|
|
||
| ScrollView CreateMainContent() | ||
| { | ||
| return new ScrollView | ||
| { | ||
| Content = new StackLayout | ||
| { | ||
| Spacing = 20, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "InputTransparent Background Test", | ||
| FontSize = 18, | ||
| FontAttributes = FontAttributes.Bold, | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }, | ||
| tapCountLabel, | ||
| new Button | ||
| { | ||
| Text = "Toggle InputTransparent", | ||
| Command = new Command(ToggleInputTransparent), | ||
| AutomationId = "ToggleInputTransparentButton" | ||
| }, | ||
| new Button | ||
| { | ||
| Text = "Toggle Background Colors", | ||
| Command = new Command(ToggleBackgroundColors), | ||
| AutomationId = "ToggleBackgroundColorsButton" | ||
| }, | ||
| redGrid, | ||
| greenGrid, | ||
| blueBorder, | ||
| purpleContent | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| Grid CreateBackgroundTestGrid(Color bgColor, bool inputTransparent, string labelText, out Label label) | ||
| { | ||
| label = new Label { Text = $"{labelText} (InputTransparent=False)", HorizontalOptions = LayoutOptions.Center, AutomationId = $"{labelText}" }; | ||
|
|
||
| Grid childGrid = new Grid | ||
| { | ||
| BackgroundColor = bgColor, | ||
| InputTransparent = inputTransparent, | ||
| Children = { label } | ||
| }; | ||
|
|
||
| AddTapGesture(childGrid); | ||
|
|
||
| Grid parentGrid = new Grid | ||
| { | ||
| WidthRequest = 200, | ||
| HeightRequest = 100, | ||
| InputTransparent = inputTransparent, | ||
| BackgroundColor = Colors.LightGray, | ||
| Children = { childGrid } | ||
| }; | ||
|
|
||
| AddTapGesture(parentGrid); | ||
| return parentGrid; | ||
| } | ||
|
|
||
| void AddTapGesture(View view) | ||
| { | ||
| view.GestureRecognizers.Add(new TapGestureRecognizer | ||
| { | ||
| Command = new Command(() => | ||
| { | ||
| tapCount++; | ||
| tapCountLabel.Text = $"Tap count: {tapCount}"; | ||
| }) | ||
| }); | ||
| } | ||
|
|
||
| void ToggleInputTransparent() | ||
| { | ||
| tapCount = 0; | ||
| tapCountLabel.Text = $"Tap count: {0}"; | ||
| redGrid.InputTransparent = !redGrid.InputTransparent; | ||
| greenGrid.InputTransparent = !greenGrid.InputTransparent; | ||
| blueBorder.InputTransparent = !blueBorder.InputTransparent; | ||
| purpleContent.InputTransparent = !purpleContent.InputTransparent; | ||
|
|
||
| redGridLabel.Text = $"Red Grid (InputTransparent={redGrid.InputTransparent})"; | ||
| greenGridLabel.Text = $"Green Grid (InputTransparent={greenGrid.InputTransparent})"; | ||
| blueBorderLabel.Text = $"Blue Border (InputTransparent={blueBorder.InputTransparent})"; | ||
| purpleContentLabel.Text = $"Purple Content (InputTransparent={purpleContent.InputTransparent})"; | ||
| } | ||
|
|
||
| void ToggleBackgroundColors() | ||
| { | ||
| redGrid.BackgroundColor = Colors.Yellow; | ||
| greenGrid.BackgroundColor = Colors.Blue; | ||
| blueBorder.BackgroundColor = Colors.LightBlue; | ||
| purpleContent.BackgroundColor = Colors.Pink; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue17389 : _IssuesUITest | ||
| { | ||
| public Issue17389(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "InputTransparent should not affect background color on Windows layouts"; | ||
|
|
||
| [Test, Order(1)] | ||
| [Category(UITestCategories.Layout)] | ||
| public void ValidateBackgroundColorDoesNotAffectInputTransparent() | ||
| { | ||
| App.WaitForElement("ToggleInputTransparentButton"); | ||
|
|
||
| string[] layouts = new[] | ||
| { | ||
| "RedGrid", | ||
| "GreenGrid", | ||
| "BlueBorder", | ||
| "PurpleContent" | ||
| }; | ||
|
|
||
| foreach (var layout in layouts) | ||
| { | ||
| App.Tap(layout); | ||
| } | ||
|
|
||
| App.WaitForElement("Tap count: 4"); | ||
| App.Click("ToggleInputTransparentButton"); | ||
|
|
||
| foreach (var layout in layouts) | ||
| { | ||
| App.Tap(layout); | ||
| } | ||
|
|
||
| App.WaitForElement("Tap count: 0"); | ||
| } | ||
|
|
||
| [Test, Order(2)] | ||
| [Category(UITestCategories.Layout)] | ||
| public void ValidateInputTransparentBackgroundColorToggle() | ||
| { | ||
| Exception? exception = null; | ||
|
|
||
| App.WaitForElement("ToggleBackgroundColorsButton"); | ||
| VerifyScreenshotOrSetException(ref exception, "BeforeToggleBackgroundColors"); | ||
|
Dhivya-SF4094 marked this conversation as resolved.
Dhivya-SF4094 marked this conversation as resolved.
Collaborator
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.
[major] Regression Prevention / UI Tests — This shared screenshot test runs with
Collaborator
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.
[moderate] Regression Prevention and Test Coverage — This baseline screenshot is captured before the test enables |
||
| App.WaitForElement("ToggleBackgroundColorsButton"); | ||
| App.Tap("ToggleBackgroundColorsButton"); | ||
| VerifyScreenshotOrSetException(ref exception, "AfterToggleBackgroundColors"); | ||
|
|
||
| if (exception != null) | ||
| { | ||
| throw exception; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| using Microsoft.UI.Xaml.Media; | ||
| using WFlowDirection = Microsoft.UI.Xaml.FlowDirection; | ||
| using WinPoint = Windows.Foundation.Point; | ||
| using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush; | ||
|
Collaborator
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.
[minor] Complexity Reduction / Dead Code — The |
||
|
|
||
| namespace Microsoft.Maui.Platform | ||
| { | ||
|
|
@@ -439,7 +440,7 @@ public static void UpdateInputTransparent(this FrameworkElement nativeView, IVie | |
|
|
||
| public static void UpdateInputTransparent(this LayoutPanel layoutPanel, ILayoutHandler handler, ILayout layout) | ||
| { | ||
| // Nothing to do yet, but we might need to adjust the wrapper view | ||
| // Nothing to do yet, but we might need to adjust the wrapper view | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.