Skip to content

Commit 981fbb8

Browse files
knsv-botknsv-botclaude
authored
fix(gantt): restore readable outside-text for done tasks in dark mode (#7456)
* fix(gantt): restore readable outside-text color for done tasks in dark mode When a Gantt done-task label is too wide to fit inside the bar, the renderer places the text outside (next to the bar) with class `taskTextOutsideLeft` or `taskTextOutsideRight` plus `doneText{N}`. The `.doneText{N}` rule uses `taskTextDarkColor !important`, which PR #7432 changed to a dark color (inverted from lightgrey) for contrast inside the bar. That `!important` also overrides the lighter `taskTextOutsideColor` that `.taskTextOutside{N}` sets, making outside-label text black/dark on the dark diagram background. Fix: add combined-class selectors (`.doneText{N}.taskTextOutsideLeft/Right`) after the `.doneText{N}` block, using `taskTextOutsideColor !important`. The combined selectors have higher specificity and appear later in the cascade, so they win over the single-class rule. Same fix applied to `.doneCritText{N}`. Fixes regression from PR #7432 (fix for #5979). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(gantt): add e2e snapshot for done-task outside-text in dark mode Covers the regression from #7433 where done-task labels displayed outside the bar (text too wide for the bar width) rendered in unreadable dark color in dark theme. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test(gantt): add separate inside/outside e2e snapshots for dark mode done tasks Split the dark mode done-task coverage into two explicit tests: - inside-text: label fits within the bar (long bar, short label) - outside-text: label overflows the bar (short bar, long label) — regression case for #7433 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: knsv-bot <knsv-bot@macos.shared> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0d5e35a commit 981fbb8

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix(gantt): restore readable outside-text color for done tasks in dark mode

cypress/integration/rendering/gantt.spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,4 +884,38 @@ describe('Gantt diagram', () => {
884884
{ theme: 'dark' }
885885
);
886886
});
887+
it('should render done task inside-text readable in dark mode', () => {
888+
imgSnapshotTest(
889+
`
890+
gantt
891+
dateFormat YYYY-MM-DD
892+
title Gantt dark mode done-task inside-text readability
893+
894+
section A section
895+
Done :done, 2014-01-06, 14d
896+
Active :active, 2014-01-20, 14d
897+
898+
section Critical tasks
899+
Done critical :crit, done, 2014-01-06, 14d
900+
`,
901+
{ theme: 'dark' }
902+
);
903+
});
904+
it('should render done task outside-text readable in dark mode (regression #7433)', () => {
905+
imgSnapshotTest(
906+
`
907+
gantt
908+
dateFormat YYYY-MM-DD
909+
title Gantt dark mode done-task outside-text readability
910+
911+
section A section
912+
A very long label that will not fit inside the short bar :done, 2014-01-06, 1d
913+
Active short bar :active, 2014-01-07, 1d
914+
915+
section Critical tasks
916+
A very long label that will not fit inside the short bar :crit, done, 2014-01-06, 1d
917+
`,
918+
{ theme: 'dark' }
919+
);
920+
});
887921
});

packages/mermaid/src/diagrams/gantt/styles.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ const getStyles = (options) =>
191191
fill: ${options.taskTextDarkColor} !important;
192192
}
193193
194+
/* Done task text displayed outside the bar sits against the diagram background,
195+
not against the done-task bar, so it must use the outside/contrast color. */
196+
.doneText0.taskTextOutsideLeft,
197+
.doneText0.taskTextOutsideRight,
198+
.doneText1.taskTextOutsideLeft,
199+
.doneText1.taskTextOutsideRight,
200+
.doneText2.taskTextOutsideLeft,
201+
.doneText2.taskTextOutsideRight,
202+
.doneText3.taskTextOutsideLeft,
203+
.doneText3.taskTextOutsideRight {
204+
fill: ${options.taskTextOutsideColor} !important;
205+
}
206+
194207
195208
/* Tasks on the critical line */
196209
@@ -237,6 +250,18 @@ const getStyles = (options) =>
237250
fill: ${options.taskTextDarkColor} !important;
238251
}
239252
253+
/* Done-crit task text outside the bar — same reasoning as doneText above. */
254+
.doneCritText0.taskTextOutsideLeft,
255+
.doneCritText0.taskTextOutsideRight,
256+
.doneCritText1.taskTextOutsideLeft,
257+
.doneCritText1.taskTextOutsideRight,
258+
.doneCritText2.taskTextOutsideLeft,
259+
.doneCritText2.taskTextOutsideRight,
260+
.doneCritText3.taskTextOutsideLeft,
261+
.doneCritText3.taskTextOutsideRight {
262+
fill: ${options.taskTextOutsideColor} !important;
263+
}
264+
240265
.vert {
241266
stroke: ${options.vertLineColor};
242267
}

0 commit comments

Comments
 (0)