-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS/macCatalyst] Fix Entry and Editor BackgroundColor reset when set to null #34741
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
base: main
Are you sure you want to change the base?
Changes from all commits
f8e1b56
83efef6
29280f2
9ef6eaf
e0f3084
a873c7e
3264dac
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,69 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34611, "Entry and Editor BackgroundColor not reset to Null", PlatformAffected.iOS | PlatformAffected.macOS)] | ||
| public class Issue34611 : TestContentPage | ||
| { | ||
| Entry _entry; | ||
| Editor _editor; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| Title = "Issue34611"; | ||
|
|
||
| _entry = new Entry | ||
| { | ||
| AutomationId = "TestEntry", | ||
| Text = "Entry background should reset", | ||
| Placeholder = "Entry" | ||
| }; | ||
|
|
||
| _editor = new Editor | ||
| { | ||
| AutomationId = "TestEditor", | ||
| Text = "Editor background should reset", | ||
| HeightRequest = 120, | ||
| Placeholder = "Editor" | ||
| }; | ||
|
|
||
| var applyButton = new Button | ||
| { | ||
| AutomationId = "ApplyBackgroundColorButton", | ||
| Text = "Apply BackgroundColor" | ||
| }; | ||
|
|
||
| applyButton.Clicked += (_, _) => | ||
| { | ||
| _entry.BackgroundColor = Colors.Red; | ||
| _editor.BackgroundColor = Colors.LightBlue; | ||
| }; | ||
|
|
||
| var resetButton = new Button | ||
| { | ||
| AutomationId = "ResetToDefaultButton", | ||
| Text = "Reset to Default" | ||
| }; | ||
|
|
||
| resetButton.Clicked += (_, _) => | ||
| { | ||
| _entry.BackgroundColor = null; | ||
| _editor.BackgroundColor = null; | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Margin = new Thickness(20, 0, 20, 0), | ||
| Spacing = 12, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Apply custom backgrounds, then reset them to null." | ||
| }, | ||
| _entry, | ||
| _editor, | ||
| applyButton, | ||
| resetButton | ||
| } | ||
| }; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue34611 : _IssuesUITest | ||
| { | ||
| public Issue34611(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Entry and Editor BackgroundColor not reset to Null"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Entry)] | ||
| public void EntryAndEditorBackgroundColorShouldResetToDefaultWhenSetToNull() | ||
| { | ||
| App.WaitForElement("ApplyBackgroundColorButton"); | ||
| App.Tap("ApplyBackgroundColorButton"); | ||
| App.WaitForElement("TestEntry"); | ||
| App.Tap("ResetToDefaultButton"); | ||
| VerifyScreenshot(); | ||
|
Comment on lines
+19
to
+23
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #nullable enable | ||
| override Microsoft.Maui.Handlers.StepperHandler.GetDesiredSize(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size | ||
| override Microsoft.Maui.Platform.MauiView.DidUpdateFocus(UIKit.UIFocusUpdateContext! context, UIKit.UIFocusAnimationCoordinator! coordinator) -> void | ||
| static Microsoft.Maui.Handlers.EditorHandler.MapBackground(Microsoft.Maui.Handlers.IEditorHandler! handler, Microsoft.Maui.IEditor! editor) -> void | ||
| static Microsoft.Maui.Handlers.EntryHandler.MapBackground(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #nullable enable | ||
| override Microsoft.Maui.Handlers.StepperHandler.GetDesiredSize(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size | ||
| override Microsoft.Maui.Platform.MauiView.DidUpdateFocus(UIKit.UIFocusUpdateContext! context, UIKit.UIFocusAnimationCoordinator! coordinator) -> void | ||
| static Microsoft.Maui.Handlers.EditorHandler.MapBackground(Microsoft.Maui.Handlers.IEditorHandler! handler, Microsoft.Maui.IEditor! editor) -> void | ||
| static Microsoft.Maui.Handlers.EntryHandler.MapBackground(Microsoft.Maui.Handlers.IEntryHandler! handler, Microsoft.Maui.IEntry! entry) -> void |
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.
This UI screenshot test will execute in every platform test project that links in
TestCases.Shared.Tests, but the PR only adds a baseline snapshot underTestCases.iOS.Tests/snapshots/ios.VerifyScreenshot()will fail on other runners (Android/Windows/macCatalyst) and also on iOS 26 where the environment name switches toios-26and expects a baseline undersnapshots/ios-26. Either scope the test to iOS+MacCatalyst (e.g., file-level#if IOS || MACCATALYST/Assert.Ignoreon other platforms) and add the corresponding mac + ios-26 baselines, or add baselines for all platforms where it will run.