Skip to content
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

[bug] Tauri window theme is not propagated to webview (prefers-color-scheme) #806

Closed
tauri-bot opened this issue Dec 12, 2022 · 0 comments · Fixed by #805
Closed

[bug] Tauri window theme is not propagated to webview (prefers-color-scheme) #806

tauri-bot opened this issue Dec 12, 2022 · 0 comments · Fixed by #805
Labels
status: needs triage This issue or pull request needs to be investigated type: bug

Comments

@tauri-bot
Copy link

This issue has been upstreamed from tauri-apps/tauri#5802

Describe the bug

No matter which theme I set in the Tauri config file, the WebView always answers CSS media query prefers-color-scheme with OS color theme. According to the doc, it should only be the behavior is the theme field is None.

There is a similar issue in Electron, and they managed to fix it by "propagate preferred color scheme to the renderer".

Reproduction

  1. Set Windows color mode in Personalization to "Dark".
  2. In tauri.conf.json, set windows[0].theme to "Light".
  3. In Rust main(), call main window's theme() to make sure it is tauri::Theme::Light.
  4. In CSS, have different style for of both @media (prefers-color-scheme: light) and @media (prefers-color-scheme: dark).
  5. Observe that the section in @media (prefers-color-scheme: dark) is used.

Expected behavior

If theme() returns Light, styles in @media (prefers-color-scheme: light) should be used.

Platform and versions

Environment
  › OS: Windows 10.0.22621 X64
  › Webview2: 108.0.1462.44
  › MSVC: 
      - Visual Studio Community 2022
  › Node.js: 18.12.1
  › npm: 8.19.2
  › pnpm: 7.18.1
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.65.0
  › cargo: 1.65.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc 

Packages
  › @tauri-apps/cli [NPM]: 1.2.2
  › @tauri-apps/api [NPM]: 1.2.0
  › tauri [RUST]: 1.2.2,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.6,
  › wry [RUST]: 0.23.2,

App
  › build-type: build
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › framework: Svelte
  › bundler: Vite

App directory structure
  ├─ .git
  ├─ dist
  ├─ node_modules
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue or pull request needs to be investigated type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant