Repository navigation
fix(@vben/web-ele): the main color tone for switching between dark an… - #6678
Conversation
…d light themes has been reset
|
WalkthroughThe theme preferences watcher in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as Preferences UI
participant Watcher as Watcher(themeType, isDark, prevIsDark)
participant Theme as Theme Utils
participant Store as themeColorPrimary
UI->>Watcher: Change themeType or isDark
Watcher->>Theme: compute primaryColor from themeType
alt themeType == "custom" AND isDark != prevIsDark
Note over Watcher,Store: Skip updating themeColorPrimary on dark-mode toggle for custom theme
else
Watcher->>Store: themeColorPrimary = primaryColor || theme.color
Note right of Store: Primary color updated
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue (2)
105-111: Guard against undefined oldValue in watcher (future-proofing).Directly destructuring
oldValuecan break if this watcher is ever switched toimmediate: true(or if Vue deliversundefinedon the first run). A tiny default keeps behavior identical today while preventing accidental false positives/negatives later.Apply this minimal diff:
-watch( +watch<[BuiltinThemeType, boolean]>( () => [modelValue.value, props.isDark] as [BuiltinThemeType, boolean], - ([themeType, isDark], [_, isDarkPrev]) => { + // Default `oldValue` to current values so the "dark toggled" check is false on first run. + ([themeType, isDark], [, isDarkPrev] = [themeType, isDark]) => {
116-118: Simplify theme primary color assignment in dark-mode watcherTo make the intent clearer and reduce cognitive load from the negated condition, invert the logic and early-return when toggling dark mode on a custom theme. This preserves the existing behavior (not overriding the user’s custom color) while improving readability.
File:
packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue
Lines: 116–118Suggested change:
- if (!(theme.type === 'custom' && isDark !== isDarkPrev)) { - themeColorPrimary.value = primaryColor || theme.color; - } + if (theme.type === 'custom' && isDark !== isDarkPrev) { + // Keep user-selected custom color when toggling dark mode + return; + } + themeColorPrimary.value = primaryColor || theme.color;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/effects/layouts/src/widgets/preferences/blocks/theme/builtin.vue(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
- GitHub Check: post-update (windows-latest)
…d light themes has been reset (vbenjs#6678)
the main color tone for switching between dark and light themes has been reset
Description
Fix the issue #6615
Type of change
Summary by CodeRabbit