#8298·mermaid

Preserve computed theme defaults for partial object-valued overrides

Author: coderabbitai[bot]Created Sep 23, 2026Updated Sep 28, 2026
LabelsStatus: Triage

Summary

Theme.calculate() applies overrides, calls updateColors(), then reapplies the original top-level overrides. A partial object-valued override replaces the completed object in that final pass. For example, { bpmn: { activityFill: '#...' } } drops the other computed BPMN colors, so BPMN styles fall back to generic values such as options.mainBkg and options.nodeBorder. Partial themeVariables.xyChart overrides have the same problem.

Required change

Update shared Theme.calculate() behavior to retain computed defaults when a user supplies a partial object-valued theme override. Preserve explicitly supplied nested values. Apply the shared change consistently across theme implementations rather than fixing only BPMN. Review packages/mermaid/src/themes/theme-base.js, packages/mermaid/src/themes/theme-dark.js, packages/mermaid/src/themes/theme-neutral.js, packages/mermaid/src/themes/theme-redux-dark-color.js, and other theme implementations using the same calculation pattern.

Acceptance criteria

  • Partial themeVariables.bpmn overrides retain unspecified BPMN palette values in each theme.
  • Partial themeVariables.xyChart overrides retain unspecified xyChart values in each theme.
  • Add regression tests for partial object-valued overrides across theme implementations.
  • Review rendering snapshots, especially e2e/diagrams/xychart/render-all-the-theme-color.mmd: its override specifies 12 of the 13 base-theme xyChart keys, so legendTextColor will start using the computed theme value.

Requested by @filipsajdak. Follow-up to https://github.com/mermaid-js/mermaid/pull/8166 and https://github.com/mermaid-js/mermaid/pull/8166#discussion_r4043265248.