Open ayangweb opened 14 hours ago
Originally I was trying to achieve this by doing the following, but it was also problematic!
useAsyncEffect(async () => {
const appWindow = getCurrentWebviewWindow();
let isDark = globalStore.appearance.theme === "dark";
if (globalStore.appearance.theme === "auto") {
isDark = (await appWindow.theme()) === "dark"; // Gets the theme color of the window
// or
isDark = window.matchMedia("(prefers-color-scheme: dark)").matches; // It is also the theme color of the window, not the system theme color.
}
appWindow.setTheme(isDark ? "dark" : "light");
globalStore.appearance.isDark = isDark;
}, [globalStore.appearance.theme]);
// If the value of `appWindow.setTheme` is not null or undefined, a change in the system theme will not be triggered.
appWindow.onThemeChanged(async ({ payload }) => {
if (globalStore.appearance.theme !== "auto") return;
globalStore.appearance.isDark = payload === "dark";
});
Describe the bug
Reproduction case: https://github.com/ayangweb/tauri-input-demo
This bug is so tricky that I've been troubleshooting for ages to figure out the problem ☹️ I don't really understand why it's having this problem
Currently, tested to be a stable reproduction only on macOS, The video is quite long, so please be patient
https://github.com/user-attachments/assets/b43f019a-b212-4c30-a1b3-abac92ffb143
In my development EcoPaste, I also can stable reproducing bug!
https://github.com/user-attachments/assets/631c9056-3e26-4127-aa65-872f4a8de7f4
Reproduction
No response
Expected behavior
No response
Full
tauri info
outputStack trace
No response
Additional context
This bug was reported by a user of EcoPaste, so it's not just my computer!