Skip to content

Focus visual ignores element-level RequestedTheme, follows app/system theme instead #23242

Closed

Description

@MartinZikmund

Current behavior 🐛

When the application's effective theme differs from a subtree's RequestedTheme (e.g. system/app is Dark but a Frame/Page sets RequestedTheme=Light), the keyboard focus visual on elements inside that subtree renders with the application's theme colors instead of the element's theme colors.

For example, with Application.RequestedTheme = Dark and myFrame.RequestedTheme = Light, focusing a control inside myFrame shows the Dark-theme focus visual (white outer, black inner) instead of the expected Light-theme one (dark outer, white inner).

Expected behavior 🎯

The focus visual should follow the focused element's effective theme — its own RequestedTheme or the nearest ancestor's — matching WinUI behavior.

How to reproduce it (as minimally and precisely as possible) 🔬

  1. Run an Uno Platform app on Skia (Desktop or WebAssembly).
  2. Set Application.Current.RequestedTheme = ApplicationTheme.Dark (or let it follow a Dark system theme).
  3. Set RequestedTheme=Light on a Frame/Page containing focusable controls.
  4. Tab to a control inside that Frame.

Observed: focus visual uses Dark-theme brushes.
Expected: focus visual uses Light-theme brushes (because the focused element's effective theme is Light).

Root cause

DependencyProperty.GetDefaultValue resolves FocusVisualPrimaryBrush / FocusVisualSecondaryBrush via ResourceResolver.TryStaticRetrieval("SystemControlFocusVisualPrimaryBrush", null, …) — the null context means the lookup uses the application's active theme rather than the focused element's effective theme. WinUI resolves against targetObject->GetTheme() (see CDependencyProperty::GetDefaultFocusVisualBrush in microsoft-ui-xaml2/src/dxaml/xcp/core/core/elements/DependencyProperty.cpp).

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

WebAssembly, Desktop (Windows/macOS/Linux via Skia)

Uno.Sdk version

6.7.0-dev.29 and earlier (still reproduces on the latest dev versions, even after #23178 / #23197).

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions