Skip to content
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
69 changes: 69 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue34611.cs
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 +15 to +23
Copy link

Copilot AI Apr 1, 2026

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 under TestCases.iOS.Tests/snapshots/ios. VerifyScreenshot() will fail on other runners (Android/Windows/macCatalyst) and also on iOS 26 where the environment name switches to ios-26 and expects a baseline under snapshots/ios-26. Either scope the test to iOS+MacCatalyst (e.g., file-level #if IOS || MACCATALYST / Assert.Ignore on other platforms) and add the corresponding mac + ios-26 baselines, or add baselines for all platforms where it will run.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +23
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

After tapping "ResetToDefaultButton", the visual update may not be fully applied by the time the screenshot is taken, which can make this test flaky. Prefer using VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(...)) (and/or an explicit wait for a stable UI condition) instead of taking the screenshot immediately.

Copilot uses AI. Check for mistakes.
}
}
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/Core/src/Handlers/Editor/EditorHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ public static void MapText(IEditorHandler handler, IEditor editor)
MapFormatting(handler, editor);
}

public static void MapBackground(IEditorHandler handler, IEditor editor)
{
if (handler.PlatformView is not MauiTextView platformView)
return;

if (editor.Background is ImageSourcePaint image)
{
var provider = handler.GetRequiredService<IImageSourceServiceProvider>();
platformView.UpdateBackgroundImageSourceAsync(image.ImageSource, provider)
.FireAndForget(handler);
}
else if (editor.Background.IsNullOrEmpty())
{
platformView.RemoveBackgroundLayer();
platformView.BackgroundColor = null;
}
else
{
platformView.UpdateBackground(editor);
}
}

public static void MapTextColor(IEditorHandler handler, IEditor editor) =>
handler.PlatformView?.UpdateTextColor(editor);

Expand Down
28 changes: 26 additions & 2 deletions src/Core/src/Handlers/Entry/EntryHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@ public static void MapText(IEntryHandler handler, IEntry entry)
MapFormatting(handler, entry);
}

public static void MapBackground(IEntryHandler handler, IEntry entry)
{
if (handler.PlatformView is not MauiTextField platformView)
return;

if (entry.Background is ImageSourcePaint image)
{
var provider = handler.GetRequiredService<IImageSourceServiceProvider>();
platformView.UpdateBackgroundImageSourceAsync(image.ImageSource, provider)
.FireAndForget(handler);
return;
}
else if (entry.Background.IsNullOrEmpty())
{
platformView.RemoveBackgroundLayer();
platformView.BackgroundColor = null;
return;
}
else
{
platformView.UpdateBackground(entry);
}
}

public static void MapTextColor(IEntryHandler handler, IEntry entry)
{
handler.PlatformView?.UpdateTextColor(entry);
Expand Down Expand Up @@ -212,8 +236,8 @@ void OnEditingChanged(object? sender, EventArgs e)

VirtualView.UpdateText(platformView.Text);
}
}
}

void OnEditingEnded(object? sender, EventArgs e)
{
if (sender is MauiTextField platformView && VirtualView is IEntry virtualView)
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
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
Loading