Skip to content

[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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jul 13, 2025

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

Before After
Screen.Recording.2025-07-14.at.00.52.51.mov
Screen.Recording.2025-07-14.at.00.50.47.mov

@Copilot Copilot AI review requested due to automatic review settings July 13, 2025 22:55
@kubaflo kubaflo requested a review from a team as a code owner July 13, 2025 22:55
@kubaflo kubaflo self-assigned this Jul 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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)

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jul 13, 2025
Copy link
Contributor

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.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

if (Application.Current is null)
return;

if (args.NewHandler is null)
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Editor and Entry don't update placeholder and text color on theme change
2 participants