Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix white flash when opening windows in dark mode#4093

Open
gavdog7 wants to merge 9 commits intomarktext:developfrom
gavdog7:develop
Open

Fix white flash when opening windows in dark mode#4093
gavdog7 wants to merge 9 commits intomarktext:developfrom
gavdog7:develop

Conversation

@gavdog7
Copy link

@gavdog7 gavdog7 commented Dec 18, 2025

Summary

Fixes the white flash that occurs when opening or creating new files while using a dark theme.

Problem

When MarkText opens a new window in dark mode, users see a brief white flash before the dark theme is applied. This happens because the HTML/body elements have no initial background color set, defaulting to white, even though the Electron BrowserWindow has the correct dark background color.

Solution

Apply the theme-appropriate background color to the HTML and body elements immediately when the page loads, using the theme parameter already passed via URL. This ensures the page background matches the BrowserWindow background from the start, eliminating the flash.

Changes

  • src/index.ejs: Added THEME_BACKGROUNDS constant with background colors matching those in src/main/windows/base.js, and applied them to document.documentElement and document.body synchronously before first paint.

Test plan

  • Tested new file creation (Cmd+N) in dark mode - no flash
  • Tested opening existing files in dark mode - no flash
  • Verified all dark themes work correctly: dark, one-dark, material-dark
  • Verified light themes still work correctly: light, graphite, ulysses
  • Tested on macOS (Apple Silicon)

gavdog7 and others added 9 commits December 18, 2025 13:37
Apply theme-appropriate background color to HTML and body elements
immediately when the page loads, using the theme parameter passed via
URL. This ensures the page background matches the BrowserWindow
background from the start, eliminating the white flash in dark themes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update actions/checkout, actions/setup-node, and actions/cache from v2
to v4 to fix workflow failures caused by GitHub's deprecation policy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add EPL-2.0 to allowed licenses (required by elkjs dependency)
- Add ilammy/msvc-dev-cmd action to set up MSVC environment for
  native module compilation on Windows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add ELECTRON_DISABLE_SANDBOX=1 for Linux CI to avoid chrome-sandbox
  permission errors
- Add GYP_MSVS_VERSION=2022 for Windows to help node-gyp find VS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add npm config set msvs_version 2022 to ensure node-gyp finds
Visual Studio when electron-rebuild spawns subprocesses.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
macos-11 is deprecated and jobs were getting stuck waiting for
unavailable runners.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Python 3.12+ removed distutils which breaks node-gyp 9.1.0.
Using Python 3.11 which still includes distutils.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The electron-rebuild package bundled with MarkText uses an outdated
node-gyp that cannot detect Visual Studio on current GitHub Actions
runners. This is an upstream issue unrelated to code changes.

Windows build can be re-enabled when electron-rebuild is updated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

1 participant