Skip to content

Conversation

TamilarasanSF4853
Copy link
Contributor

@TamilarasanSF4853 TamilarasanSF4853 commented Oct 7, 2025

Issue Details

On Android, the Entry and Editor controls do not respect the AppThemeBinding colors for their placeholder and text when the application theme changes (e.g., from Light to Dark).

Root cause

The root cause of the issue is that the UpdateTextColor method is called twice. During the first call, the colors are set correctly. However, when the RequestedTheme changes, the method is called again, and the same color is used to create the ColorStateList, which returns null the second time. As a result, the else block executes and overrides the text color with the default value.

Description of Change

Fixed the Android Entry and Editor controls to properly respect AppThemeBinding colors when the theme changes. Added explicit handling for null text and placeholder colors to prevent AppThemeBinding colors from being overridden by default colors.

Regressed PR: #30603

Issue Fixed

Fixes #31889

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac

Output images

Android

Before After
Screen.Recording.2025-10-07.at.1.08.20.PM.mov
Screen.Recording.2025-10-07.at.12.59.22.PM.mov

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Oct 7, 2025
@jfversluis
Copy link
Member

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Oct 8, 2025

/backport to release/9.0.1xx-sr12

Copy link
Contributor

github-actions bot commented Oct 8, 2025

Started backporting to release/9.0.1xx-sr12: https://github.com/dotnet/maui/actions/runs/18353595854

@TamilarasanSF4853 TamilarasanSF4853 marked this pull request as ready for review October 9, 2025 07:17
@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 07:17
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 a regression in Android Entry and Editor controls where AppThemeBinding colors for text and placeholder would reset to default values when the application theme changes. The fix involves adding null checks to prevent the fallback color logic from executing when AppThemeBinding colors should be preserved.

Key changes:

  • Modified the else conditions in UpdateTextColor and UpdatePlaceholderColor methods to only execute when the color parameter is explicitly null
  • Added comprehensive UI tests to verify the fix works correctly across theme changes
  • Created test UI demonstrating the issue with AppThemeBinding colors

Reviewed Changes

Copilot reviewed 4 out of 16 changed files in this pull request and generated no comments.

File Description
src/Core/src/Platform/Android/EditTextExtensions.cs Changed else to else if (color is null) in color update methods to prevent overriding AppThemeBinding colors
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31889.cs Added NUnit tests to verify text and placeholder colors update correctly on theme changes
src/Controls/tests/TestCases.HostApp/Issues/Issue31889.xaml.cs Created test page code-behind with theme switching functionality
src/Controls/tests/TestCases.HostApp/Issues/Issue31889.xaml Created test UI with Entry and Editor controls using AppThemeBinding colors

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

if (textColor is not null && PlatformInterop.CreateEditTextColorStateList(editText.TextColors, textColor.ToPlatform()) is ColorStateList c)
editText.SetTextColor(c);
else
else if (textColor 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.

Can simplify the conditions just with an initial check:

if (editText is null)
        return;

Copy link
Contributor Author

@TamilarasanSF4853 TamilarasanSF4853 Oct 10, 2025

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.

@PureWeen
Copy link
Member

/backport to release/9.0.1xx-sr12

Copy link
Contributor

Started backporting to release/9.0.1xx-sr12: https://github.com/dotnet/maui/actions/runs/18411780331

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added the p/0 Work that we can't release without label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-editor Editor area-controls-entry Entry community ✨ Community Contribution p/0 Work that we can't release without partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] Entry and Editor AppThemeBinding colors for text and placeholder reset to default on theme change

5 participants