-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android][Regression] Fixed Entry and Editor AppThemeBinding colors for text and placeholder reset to default on theme change #31891
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
Open
TamilarasanSF4853
wants to merge
7
commits into
dotnet:main
Choose a base branch
from
TamilarasanSF4853:fix-31889
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5396711
added snapshots and fix
TamilarasanSF4853 822210d
removed test cases
TamilarasanSF4853 375dfb7
added the test cases and snapshots
TamilarasanSF4853 b01e1fa
added braces
TamilarasanSF4853 0f390cf
added mac and windows snapshots
TamilarasanSF4853 96a9a0a
added mac and windows snapshots
TamilarasanSF4853 6c98489
added snapshot
TamilarasanSF4853 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
Binary file added
BIN
+30.3 KB
...android/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.7 KB
...ndroid/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26 KB
.../snapshots/android/EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.1 KB
...snapshots/android/EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
src/Controls/tests/TestCases.HostApp/Issues/Issue31889.xaml
This file contains hidden or 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,46 @@ | ||
<?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" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample" | ||
x:Class="Maui.Controls.Sample.Issues.Issue31889"> | ||
<VerticalStackLayout Spacing="20" | ||
HorizontalOptions="Center"> | ||
<HorizontalStackLayout> | ||
<Label Text="Entry: " | ||
VerticalOptions="Center" | ||
TextColor="{AppThemeBinding Light=Black, Dark=White}"/> | ||
<local:UITestEntry AutomationId="TestEntry" | ||
IsCursorVisible="False" | ||
IsSpellCheckEnabled="False" | ||
Placeholder="Entry Placeholder" | ||
PlaceholderColor="{AppThemeBinding Light=Green, Dark=Orange}" | ||
Text="Entry Text" | ||
TextColor="{AppThemeBinding Light=Blue, Dark=Red}" | ||
WidthRequest="200"/> | ||
</HorizontalStackLayout> | ||
<HorizontalStackLayout> | ||
<Label Text="Editor: " | ||
TextColor="{AppThemeBinding Light=Black, Dark=White}" | ||
VerticalOptions="Center"/> | ||
<local:UITestEditor AutomationId="TestEditor" | ||
IsCursorVisible="False" | ||
IsSpellCheckEnabled="False" | ||
Placeholder="Editor Placeholder" | ||
PlaceholderColor="{AppThemeBinding Light=Green, Dark=Orange}" | ||
Text="Editor Text" | ||
TextColor="{AppThemeBinding Light=Blue, Dark=Red}" | ||
WidthRequest="200"/> | ||
</HorizontalStackLayout> | ||
<HorizontalStackLayout Spacing="10" | ||
HorizontalOptions="Center"> | ||
<Button AutomationId="LightThemeButton" | ||
Text="Light Theme" | ||
Clicked="OnLightThemeButtonClicked" | ||
HorizontalOptions="Center"/> | ||
<Button AutomationId="DarkThemeButton" | ||
Text="Dark Theme" | ||
Clicked="OnDarkThemeButtonClicked" | ||
HorizontalOptions="Center"/> | ||
</HorizontalStackLayout> | ||
</VerticalStackLayout> | ||
</ContentPage> |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.HostApp/Issues/Issue31889.xaml.cs
This file contains hidden or 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,26 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 31889, "Entry and Editor AppThemeBinding colors for text and placeholder reset to default on theme change", PlatformAffected.Android)] | ||
public partial class Issue31889 : ContentPage | ||
{ | ||
public Issue31889() | ||
{ | ||
InitializeComponent(); | ||
this.SetAppThemeColor(BackgroundColorProperty, Colors.White, Colors.Black); | ||
} | ||
public void OnLightThemeButtonClicked(object sender, EventArgs e) | ||
{ | ||
if (Application.Current is not null) | ||
{ | ||
Application.Current.UserAppTheme = AppTheme.Light; | ||
} | ||
} | ||
|
||
public void OnDarkThemeButtonClicked(object sender, EventArgs e) | ||
{ | ||
if (Application.Current is not null) | ||
{ | ||
Application.Current.UserAppTheme = AppTheme.Dark; | ||
} | ||
} | ||
} |
Binary file added
BIN
+13.6 KB
...ots/mac/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.5 KB
...ts/mac/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.4 KB
...ests/snapshots/mac/EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
...sts/snapshots/mac/EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions
61
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs
This file contains hidden or 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,61 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue31889 : _IssuesUITest | ||
{ | ||
public Issue31889(TestDevice testDevice) : base(testDevice) { } | ||
|
||
private const string TestEntryId = "TestEntry"; | ||
private const string TestEditorId = "TestEditor"; | ||
private const string DarkThemeButtonId = "DarkThemeButton"; | ||
private const string LightThemeButtonId = "LightThemeButton"; | ||
private const string DoneButtonId = "Done"; | ||
private const string TextColorDarkTheme = "EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme"; | ||
private const string TextColorLightTheme = "EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme"; | ||
private const string PlaceholderColorDarkTheme = "EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme"; | ||
private const string PlaceholderColorLightTheme = "EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnLightTheme"; | ||
public override string Issue => "Entry and Editor AppThemeBinding colors for text and placeholder reset to default on theme change"; | ||
|
||
[Test, Order(1)] | ||
[Category(UITestCategories.Entry)] | ||
public void EntryAndEditorTextColorAppThemeBindingUpdatesOnThemeChange() | ||
{ | ||
App.WaitForElement(TestEntryId); | ||
App.WaitForElement(DarkThemeButtonId); | ||
App.Tap(DarkThemeButtonId); | ||
VerifyScreenshot(TextColorDarkTheme); | ||
App.WaitForElement(LightThemeButtonId); | ||
App.Tap(LightThemeButtonId); | ||
VerifyScreenshot(TextColorLightTheme); | ||
} | ||
|
||
[Test, Order(2)] | ||
[Category(UITestCategories.Entry)] | ||
public void EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnThemeChange() | ||
{ | ||
App.WaitForElement(TestEntryId); | ||
App.ClearText(TestEntryId); | ||
|
||
App.WaitForElement(TestEditorId); | ||
App.ClearText(TestEditorId); | ||
#if MACCATALYST // On macOS, clearing the text in the Editor does not remove the full content. | ||
App.ClearText(TestEditorId); | ||
#endif | ||
#if IOS | ||
if (App.IsKeyboardShown()) | ||
{ | ||
App.WaitForElement(DoneButtonId); | ||
App.Tap(DoneButtonId); | ||
} | ||
#endif | ||
App.WaitForElement(DarkThemeButtonId); | ||
App.Tap(DarkThemeButtonId); | ||
VerifyScreenshot(PlaceholderColorDarkTheme); | ||
App.WaitForElement(LightThemeButtonId); | ||
App.Tap(LightThemeButtonId); | ||
VerifyScreenshot(PlaceholderColorLightTheme); | ||
} | ||
} |
Binary file added
BIN
+10.7 KB
...windows/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.5 KB
...indows/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10 KB
.../snapshots/windows/EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.54 KB
...snapshots/windows/EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.4 KB
...ots/ios/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39 KB
...ts/ios/EntryAndEditorPlaceholderTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.4 KB
...ests/snapshots/ios/EntryAndEditorTextColorAppThemeBindingUpdatesOnDarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.9 KB
...sts/snapshots/ios/EntryAndEditorTextColorAppThemeBindingUpdatesOnLightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
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.
Can simplify the conditions just with an initial check:
Uh oh!
There was an error while loading. Please reload this page.
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.
@jsuarezruiz When the CreateEditTextColorStateList method is called a second time with the same color, it returns null. As a result, the else block is executed even when a TextColor is provided through the Entry or Editor controls, causing it to fall back to the default color. To prevent this, an else if condition was added to check whether the TextColor is set. Now, the else block executes only when the TextColor is null, ensuring that the provided text color is not overridden.