-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Editor and Entry don't update placeholder and text color on theme change - fix #30603
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?
Conversation
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.
Pull Request Overview
This PR fixes an issue where Editor and Entry controls on Android don't update their placeholder and text colors when the system theme changes between light and dark modes. The fix implements theme-aware color fallbacks and ensures proper event handling for theme changes.
Key changes:
- Enhanced EditText extension methods to fall back to system theme colors when no explicit color is set
- Added theme change event handling in InputView to trigger property updates
- Fixed event timing in Application class for proper theme change propagation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Core/src/Platform/Android/EditTextExtensions.cs |
Enhanced color update methods to use system theme colors as fallback and fixed layout direction reference |
src/Controls/src/Core/InputView/InputView.cs |
Added theme change event subscription to trigger color property updates |
src/Controls/src/Core/Application/Application.cs |
Reordered property change notification timing for theme changes |
Comments suppressed due to low confidence (1)
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
if (Application.Current is null) | ||
return; | ||
|
||
if (args.NewHandler is null) |
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.
You're only unsubscribing when NewHandler is null, but you should unsubscribe whenever there's an OldHandler
if (args.OldHandler is not null)
Application.Current.RequestedThemeChanged -= OnRequestedThemeChanged;
{ | ||
App.WaitForElement("changeThemeButton"); | ||
App.Tap("changeThemeButton"); | ||
VerifyScreenshot(); |
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.
Could be also interesting to modify the test to set the system theme.
Can do it using
public static void SetDarkTheme(this IApp app) |
{ | ||
if (PlatformInterop.CreateEditTextColorStateList(editText.TextColors, textColor.ToPlatform()) is ColorStateList c) | ||
editText.SetTextColor(c); | ||
var typedValue = new TypedValue(); |
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 you include a couple of comments here? Like, // Fallback to system default color
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issues Fixed
Fixes #30602
Screen.Recording.2025-07-14.at.00.52.51.mov
Screen.Recording.2025-07-14.at.00.50.47.mov