Skip to content

Conversation

@Illustar0
Copy link

Closes #2914

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When the user set the application theme to AppTheme.System, the service would correctly apply ElementTheme.Default to follow the operating system's theme.

However, the first time the system theme changed (e.g., from light to dark), the ElementThemeChanged event handler would re-apply the new theme (AppTheme.Dark) as a permanent setting. This had two negative effects:

  • It overwrote the user's preference: The saved setting was changed from AppTheme.System to AppTheme.Dark.
  • It changed the active theme request: The RequestedTheme property was updated from ElementTheme.Default to the fixed ElementTheme.Dark.

As a result, the application would no longer respond to any future system theme changes, effectively "locking" the theme to whatever it first switched to.

What is the new behavior?

With the corrected logic, the ElementThemeChanged event handler behaves differently:

  • It first checks if the user's saved preference is indeed AppTheme.System.
  • If it is, the handler only fires a notification (ThemeChanged event) to inform other parts of the app that the visual theme has changed.
  • Crucially, it does not call any methods to set or save the theme.

This ensures that the RequestedTheme property remains ElementTheme.Default and the user's AppTheme.System preference is preserved. The application now correctly follows all subsequent system theme changes without getting locked.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

Tested on the stable branch with Uno.SDK 6.3.28 + Uno.Extensions 6.2.3, and it works correctly.

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2025

CLA assistant check
All committers have signed the CLA.

@Illustar0
Copy link
Author

Hi @kazo0 ,

When you have a moment, could you please take a look at this PR?

@Illustar0 Illustar0 requested a review from kazo0 November 19, 2025 16:05
@kazo0 kazo0 requested a review from Copilot November 19, 2025 16:27
Copilot finished reviewing on behalf of kazo0 November 19, 2025 16:30
Copy link
Contributor

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 the ThemeService would incorrectly overwrite a user's AppTheme.System preference when the operating system's theme changed, effectively "locking" the application to whichever theme it first switched to.

Key Changes:

  • Refactored ElementThemeChanged to check the saved theme preference before reacting to OS theme changes
  • The handler now only fires a notification event when the user preference is AppTheme.System, avoiding unintended theme persistence
  • Removed the call to InternalSetThemeAsync from the event handler to preserve the user's original preference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Illustar0 Illustar0 requested a review from Copilot November 19, 2025 17:27
Copilot finished reviewing on behalf of Illustar0 November 19, 2025 17:29
Copy link
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Illustar0
Copy link
Author

Tested again on the stable branch with Uno.SDK 6.3.28 + Uno.Extensions 6.2.3, and it works correctly.

@Illustar0
Copy link
Author

@kazo0

@Illustar0
Copy link
Author

@kazo0 Thanks for the approval! Could you please merge this?

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.

[Desktop] system theme not followed

3 participants