Skip to content

test: Validate root element requested theme behavior #21184

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: master
Choose a base branch
from

Conversation

MartinZikmund
Copy link
Member

GitHub Issue: closes https://github.com/unoplatform/kahua-private/issues/307

PR Type: 🐞 Bugfix

What is the current behavior? 🤔

When RequestedTheme is set on root control before it is loaded, it is not properly applied to the application-level theme.

What is the new behavior? 🚀

Applied

PR Checklist ✅

Please check if your PR fulfills the following requirements:

@Copilot Copilot AI review requested due to automatic review settings July 31, 2025 16:56
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 bug where RequestedTheme set on a root control before loading was not properly applied to the application-level theme. The fix ensures theme synchronization occurs both during the loading phase and when theme changes are made.

Key changes:

  • Refactored theme synchronization logic into a reusable method
  • Added theme sync during the loading phase to handle pre-load theme settings
  • Enhanced test coverage with validation for the fixed behavior

Reviewed Changes

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

File Description
src/Uno.UI/UI/Xaml/FrameworkElement.cs Refactored theme sync logic and added sync during loading phase
src/Uno.UI/UI/Xaml/Application.cs Added new method to sync theme from XamlRoot with null validation
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Window.cs Added test to validate theme behavior when set before loading
src/Uno.UI.RuntimeTests/Helpers/ThemeHelper.cs Added CurrentTheme property for test utilities
Comments suppressed due to low confidence (1)

src/Uno.UI.RuntimeTests/Helpers/ThemeHelper.cs:30

  • The new CurrentTheme property is not being used in any tests within this PR. Consider adding a test that validates this property works correctly or remove it if it's intended for future use.
		public static ElementTheme CurrentTheme

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21184/docs/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21184/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 172514 has failed on Uno.UI - CI.

@MartinZikmund MartinZikmund force-pushed the dev/mazi/requestedtheme-early branch from 018f216 to 981606f Compare August 2, 2025 08:09
@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21184/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21184/docs/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 172652 has failed on Uno.UI - CI.

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

Successfully merging this pull request may close these issues.

3 participants