Repository navigation
fix(theming): focused NumberBox/ComboBox text is black in dark theme (backport #24091) - #25765
Merged
agneszitte merged 7 commits intoOct 27, 2026
Merged
Conversation
1 of 5 tasks
agneszitte
approved these changes
Oct 27, 2026
ramezgerges
pushed a commit
to ramezgerges/uno
that referenced
this pull request
Nov 2, 2026
…orm#25765), it doesn't build on 6.x The cherry-picked fix adds members to the DependencyObject class (GetTheme, WalkTheme, IsProcessingThemeWalk, GetVisualStateSetterResolutionTheme). On 6.x DependencyObject is still an interface, so Uno.UI no longer compiles (CS1061/CS0117 in ResourceResolver.cs and DependencyObjectStore.Theming.cs, the same errors as 6.8's build 241913 (same code)). A 6.x port of unoplatform#24091 needs its own change, validated by CI. This reverts commit eaefbb6, reversing changes made to 8fa10d7. Related to unoplatform#24021 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GitHub Issue: closes #24021
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia, text typed into a focused
NumberBoxor editableComboBoxrendered black while the app was in dark theme, making it nearly unreadable.Both templates carry (verbatim from current WinUI) a
Focusedvisual state that setsContentElement.RequestedTheme="Light"on the innerTextBox. In WinUI that is harmless; in Uno it exposed two distinct defects — though not one per control: the foreground-freeze defect affects both controls, while the setter-resolution defect affects only the editableComboBox.NumberBoxapplies its focused foreground throughObjectAnimationUsingKeyFrames, whose keyframe value resolves under its own templated-parent theme and was already correct — so the freeze fix alone makesNumberBoxpass, whileComboBoxneeds both fixes (confirmed by ablation of the hunks; thanks @MartinZikmund for measuring this).1. Foreground freeze overrode an explicitly-set
Foreground(both controls)FrameworkElement.NotifyThemeChangedForInheritedProperties(freeze: true)froze the Light-themeDefaultTextForegroundThemeBrush(black) onto the boundary element and its children, even when that element already had aForegroundset locally, by style, or by animation.WinUI (
framework.cpp,NotifyThemeChangedForInheritedProperties) skips the entire freeze in that case — "there is nothing to do, because that value will be used". Uno only skipped theSetValuewhile still recording_themeForeground/_isForegroundFrozen, which then blocked the explicit value from cascading to children through DP inheritance. On Skia the typed text is theTextBoxViewDisplayBlock, which inheritsForegroundfromContentElement— so it picked up the frozen black brush. This corrupts the child display block regardless of how the focused foreground was applied, which is why it hits both controls.Fix: early-return when the foreground precedence is above
Inheritance. The bail clears only the stored_themeForegroundbrush an earlier walk may have left (Uno keeps it in a separate field, while WinUI shares the localForegroundslot, so only Uno can leak it to children) and leaves_isForegroundFrozenuntouched — WinUI's bail is a pure cleanup jump that writes no freeze state, so the boundary keeps blocking cross-boundaryForegroundinheritance.2. VisualState setter
{ThemeResource}re-resolved under its target's own theme (editable ComboBox only)A
{ThemeResource}inside aVisualStateSetteris registered on the target element in Uno. When the same state also appliedRequestedTheme="Light"to that target, the resulting theme walk re-resolvedTextControlForegroundFocusedunder Light and produced a black brush.In WinUI the resource reference lives on the
SetterDO, which sits in the template'sVisualStateGroups— outside the target's subtree — so it never resolves under the target'sRequestedTheme.Fix:
DependencyObjectStore.GetVisualStateSetterResolutionTheme()returns the ambient theme surrounding the target, applied at the three resolution sites (UpdateThemeReference,InnerUpdateResourceBindingsUnsafe,ResourceResolver.ApplyVisualStateSetter). It is deliberately scoped to boundaries applied by the state itself (RequestedThemeatAnimationsprecedence); a XAML-authoredRequestedThemekeeps Uno's existing element-level theming semantics for setter targets.Mid-walk, an ancestor's persisted theme is stale (it is persisted only after its subtree completes), so the ambient is read from the parent's in-flight walk theme when the parent is still processing a theme walk.
When the parent has no established per-object theme — the state of every element in an app that never switches theme at runtime, since only a theme walk persists per-object themes — the ambient now falls back to the application base theme (
FrameworkTheming.GetBaseTheme()).ResolveOwnerTheme's owner-less fallback instead reads the requested-theme-for-subtree slot, which mid-boundary already carries the very Light theme being escaped, silently turning the escape into a no-op — so the fix did nothing in exactly the cold-start-dark scenario #24021 reports. Caught in review by @MartinZikmund. The fallback isUNO_HAS_ENHANCED_LIFECYCLE-only; native targets keep their existing behavior.Behavior change
Theme resolution changes in two observable ways, both toward WinUI parity:
Foreground(local / style / animation) no longer has the theme's default foreground frozen over it — and no longer propagates that frozen default to its children — when it acts as a theme boundary.{ThemeResource}in aVisualStateSetternow resolves under the ambient theme rather than the target's ownRequestedTheme, only when thatRequestedThemewas applied by a visual state.Existing app code that (intentionally or not) relied on the frozen-default behaviour could see a different foreground on such elements. No public API changed.
Validation
SamplesApp.Skia.Generic(Release, net10.0) — 0 warnings, 0 errors.Given_ElementTheme— 115 tests, 114 passed. The regression tests fail before their respective fixes and pass after:When_NumberBox_Focused_In_Dark_Theme_Text_Is_Light(freeze fix)When_Editable_ComboBox_Focused_In_Dark_Theme_Text_Is_Light(freeze + setter-resolution fixes)When_Editable_ComboBox_Focused_In_Dark_Theme_Without_Theme_Walk_Text_Is_Light(base-theme fallback) — stages the never-theme-switched cold start (the exact [Skia] the input foreground of NumberBox or ComboBox is black at dark theme #24021 scenario) by clearing the per-object themes the harness's theme switch persists; on a build without the fallback it fails with the focused text at#E4000000(black).When_Editable_ComboBox_Focused_In_Dark_Theme_ContentElement_Foreground_Is_Light— platform-agnostic variant asserting the setter's direct target (ContentElement.Foreground, no Skia display-block dependency); it is also enabled for native WASM to cover the unguardedApplyVisualStateSetterpath there. Native runtime tests are excluded from PR CI by design, so it first executes there on the post-mergemasterbranch build;Uno.UI.RuntimeTests.Wasm(and the changedUno.UIsources under__WASM__) were compile-validated locally.BorderElement.Backgroundis the darkTextControlBackgroundFocusedvalue (#B31E1E1E), proving the Focused state actually ran and resolved Dark — the Dark dictionary aliases all text-control foregrounds to the same light brush, so the foreground assert alone can't distinguish "resolved correctly" from "state never applied".When_Flyout_Closed_Target_Does_Not_Hold_Flyout, is a pre-existing GC/leak-sensitive test that fails identically on the unmodified branch — unrelated to this change.Not yet measured
PlatformConditionalready excludes them). Native WASM has direct coverage through theContentElementtest above, but native runtime tests only run on branch builds — first execution is master's post-merge build;Screenshots Compare Test Runresults remain the broader check.PR Checklist ✅
Screenshots Compare Test Runresults. — to be validated once the CI run completesThis is an automatic backport of pull request #24091 done by [Mergify](https://mergify.com).