Skip to content

fix: support dark mode with custom/legacy themes#9093

Open
ericokuma wants to merge 2 commits intomainfrom
cursor/ENG-1067-dark-mode-custom-themes-1694
Open

fix: support dark mode with custom/legacy themes#9093
ericokuma wants to merge 2 commits intomainfrom
cursor/ENG-1067-dark-mode-custom-themes-1694

Conversation

@ericokuma
Copy link
Contributor

Fix: Dark Mode not working with Custom Themes (ENG-1067)

Custom themes using the legacy format (primaryColorRaw/secondaryColorRaw) or themes that only define light colors without explicit dark colors were broken in dark mode.

Root Cause

Three places in the theme system explicitly excluded legacy theme colors from dark mode:

  1. theme.ts processTheme() — Returned empty dark colors {} for legacy themes. When generateCSS() processed these, it emitted --var: unset; for every theme variable in the .dark .dashboard-theme-boundary block, which actively removed the custom theme colors in dark mode.

  2. theme-manager.ts resolveThemeColors() — Only fell back to primaryColorRaw/secondaryColorRaw when !isThemeModeDark, so charts in dark mode received default colors instead of the custom theme colors.

  3. theme-manager.ts resolveThemeObject() — The hasLegacyColors guard required !isThemeModeDark, so dark mode returned undefined and canvas chart components got no theme object.

Fix

  • Generate a proper dark palette from legacy colors using processColors(legacyColors, true), which applies createDarkVariation() for perceptually appropriate dark mode colors.
  • Allow resolveThemeColors() to fall back to legacy color fields in both light and dark modes.
  • Allow resolveThemeObject() to recognize legacy colors in both modes.

Files Changed

  • web-common/src/features/themes/theme.ts
  • web-common/src/features/themes/theme-manager.ts

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Closes ENG-1067

Linear Issue: ENG-1067

Open in Web Open in Cursor 

When custom themes use the legacy format (primaryColorRaw/secondaryColorRaw)
or only define light colors without explicit dark colors, dark mode was broken
because:

1. theme.ts processTheme() returned empty dark colors ({}) for legacy themes,
   causing generateCSS() to emit '--var: unset' which removed theme variables
   in dark mode.
2. theme-manager.ts resolveThemeColors() only fell back to legacy color fields
   in light mode, returning default colors in dark mode.
3. theme-manager.ts resolveThemeObject() only recognized legacy colors in
   light mode, returning undefined for dark mode.

Fixes:
- Generate dark palette from legacy colors using processColors(legacyColors, true)
  which applies createDarkVariation() for proper dark mode colors.
- Allow resolveThemeColors() to fall back to legacy color fields in both modes.
- Allow resolveThemeObject() to recognize legacy colors in both modes.

Resolves ENG-1067

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@ericokuma ericokuma requested a review from Di7design March 20, 2026 20:53
@ericokuma
Copy link
Contributor Author

Screenshot 2026-03-20 at 11 40 08 PM Seems to be working now for me :)

Co-authored-by: ericokuma <ericokuma@users.noreply.github.com>
@ericokuma ericokuma requested a review from AdityaHegde March 21, 2026 06:41
@ericokuma ericokuma marked this pull request as ready for review March 21, 2026 06:41
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.

2 participants