Skip to content

fix(gantt): restore readable outside-text for done tasks in dark mode - #7456

Merged
ashishjain0512 merged 3 commits into
masterfrom
bug/7433_gantt-done-outside-text-dark-mode
Mar 6, 2026
Merged

ashishjain0512 merged 3 commits into
masterfrom
bug/7433_gantt-done-outside-text-dark-mode

Conversation

@knsv-bot

@knsv-bot knsv-bot commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Regression fix for a side-effect introduced by PR #7432 (fix for #5979).

  • When a Gantt done-task label is wider than its bar, the renderer positions the text outside the bar using classes taskTextOutsideLeft/taskTextOutsideRight combined with doneText{N}.
  • The .doneText{N} rule uses taskTextDarkColor !important. PR fix(gantt): readable done-task text in dark theme #7432 changed taskTextDarkColor in the dark theme to a dark color (inverted from lightgrey) for contrast inside the bar.
  • That !important also overrides the lighter taskTextOutsideColor set by .taskTextOutside{N}, making outside-label text black/dark on the dark diagram background — unreadable.

Fix: Add combined-class selectors (.doneText{N}.taskTextOutsideLeft/Right) after the .doneText{N} block, using taskTextOutsideColor !important. Same applied to .doneCritText{N}. The combined selectors appear later in the cascade and win by both specificity and source order.

Changes

  • packages/mermaid/src/diagrams/gantt/styles.js — two new CSS override blocks for outside done/done-crit task text
  • cypress/integration/rendering/gantt.spec.js — three e2e snapshot tests covering inside-bar and outside-bar done task text in dark theme
  • .changeset/fix-gantt-done-outside-text-dark.md — patch changeset

Verification

  • Unit tests pass (pnpm vitest run packages/mermaid/src/themes/)
  • Lint passes (pre-commit hook)
  • E2E visual snapshots: new tests added; Argos will verify on CI

🤖 Generated with Claude Code

knsv-bot and others added 3 commits March 6, 2026 10:11
…k 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>
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>
…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>
@changeset-bot

changeset-bot Bot commented Mar 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 48ce939

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mermaid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the Type: Bug / Error Something isn't working or is incorrect label Mar 6, 2026
@knsv
knsv marked this pull request as ready for review March 6, 2026 09:18
@codecov

codecov Bot commented Mar 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.53%. Comparing base (547e6d5) to head (48ce939).
⚠️ Report is 449 commits behind head on master.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/gantt/styles.js 0.00% 23 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #7456      +/-   ##
=========================================
- Coverage    3.59%   3.53%   -0.06%     
=========================================
  Files         475     494      +19     
  Lines       47191   49068    +1877     
  Branches      735     770      +35     
=========================================
+ Hits         1696    1735      +39     
- Misses      45495   47333    +1838     
Flag Coverage Δ
unit 3.53% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/gantt/styles.js 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci

argos-ci Bot commented Mar 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 403 changed, 2 added Mar 6, 2026, 9:29 AM

@ashishjain0512 ashishjain0512 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sisyphus-bot]

Review — fix(gantt): restore readable outside-text for done tasks in dark mode

Thanks for catching and fixing this regression quickly! The analysis in the PR description is clear and the CSS cascade reasoning is spot-on.


What's working well

🎉 [praise] Excellent root-cause analysis in the PR body — tracing the specificity conflict between .doneText{N} and .taskTextOutside{N} through the !important cascade makes the fix easy to verify. This is exactly how regression fix PRs should be documented.

🎉 [praise] Great test coverage — the three new e2e tests cover both inside-bar and outside-bar done text in dark mode, plus done-crit outside text. The use of a 1-day bar with a long label is a smart way to force the outside-text code path.


Things to address

🟢 [nit] The e2e test title references #7433 ("regression #7433" at cypress/integration/rendering/gantt.spec.js), but #7433 is the type-fest dependency PR. Based on the PR body, the regression was introduced by #7432 (the fix for #5979). Minor, but worth fixing so future archaeology leads to the right commit — suggest changing the test name to reference #7432.


Security

No XSS or injection issues identified. The new ${options.taskTextOutsideColor} interpolations follow the exact same pattern already used throughout styles.js. Theme variables are validated against a strict allowlist regex in sanitizeDirective.ts, compiled through stylis, and the final SVG is sanitized by DOMPurify. No new attack surface introduced.


Summary

Clean, focused regression fix. The CSS approach (combined-class selectors winning by both specificity and source order) is correct and maintainable. The changeset is appropriate (patch bump). Just the base branch question to resolve — let's get this across the finish line!

@ashishjain0512
ashishjain0512 merged commit 981fbb8 into master Mar 6, 2026
18 checks passed
@ashishjain0512
ashishjain0512 deleted the bug/7433_gantt-done-outside-text-dark-mode branch March 6, 2026 10:24
sidharthv96 added a commit that referenced this pull request Mar 6, 2026
* 'master' of https://github.com/mermaid-js/mermaid:
  fix(gantt): restore readable outside-text for done tasks in dark mode (#7456)
  fix(elk): scope rounded edge curve to ELK layout only (#7454)
@github-actions github-actions Bot mentioned this pull request Mar 9, 2026
ashishjain0512 added a commit that referenced this pull request Mar 26, 2026
* changeset-release/master:
  fix pnpm lock file
  Fix: ER diagram edge label positioning (#7453)
  chore: Update coupon
  fix(gantt): restore readable outside-text for done tasks in dark mode (#7456)
  fix(elk): scope rounded edge curve to ELK layout only (#7454)
  Version Packages
  fix: plausible build
  chore: Update plausible
  chore: Update release version in docs
  chore: Track editor picker selection
  fix: update broken docsy link and exclude bot-blocked domains from link checker
  chore: replace MERMAID_RELEASE_VERSION placeholders with current version
  fix: correct package name in changeset slow-lemons-know
  Updated Hero text
  Version Packages
  Fixed issue with hero text
  chore: Update banner with coupon
  Update link with source
  Updating the Hero on the docs side

# Conflicts:
#	.changeset/rounded-edge-curves.md
#	.changeset/weak-tools-pay.md
#	cypress/integration/rendering/flowchart-v2.spec.js
#	packages/mermaid/CHANGELOG.md
#	packages/mermaid/src/rendering-util/createText.ts
#	packages/mermaid/src/rendering-util/rendering-elements/edges.js
#	packages/tiny/CHANGELOG.md
#	pnpm-lock.yaml
ashishjain0512 added a commit that referenced this pull request Apr 1, 2026
* master: (24 commits)
  Version Packages (#7561)
  Release candidate 11.14.0 (#7526)
  chore: Editor Picker V2 (#7497)
  Setting the link to Get started to the correct on
  Version Packages (#7466)
  fix: use correct package name for elk
  dummy commit
  Fix: ER diagram edge label positioning (#7453)
  chore: Update coupon
  fix(gantt): restore readable outside-text for done tasks in dark mode (#7456)
  fix(elk): scope rounded edge curve to ELK layout only (#7454)
  fix: plausible build
  chore: Update plausible
  chore: Update release version in docs
  chore: Track editor picker selection
  fix: update broken docsy link and exclude bot-blocked domains from link checker
  chore: replace MERMAID_RELEASE_VERSION placeholders with current version
  fix: correct package name in changeset slow-lemons-know
  Updated Hero text
  Version Packages
  ...

# Conflicts:
#	.changeset/weak-tools-pay.md
#	docs/syntax/architecture.md
#	docs/syntax/timeline.md
#	docs/syntax/treeView.md
#	docs/syntax/wardley.md
#	docs/syntax/xyChart.md
#	packages/examples/CHANGELOG.md
#	packages/examples/package.json
#	packages/mermaid/CHANGELOG.md
#	packages/mermaid/package.json
#	packages/mermaid/src/diagrams/git/gitGraphRenderer.ts
#	packages/mermaid/src/docs/.vitepress/components/EditorSelectionModal.vue
#	packages/mermaid/src/docs/syntax/architecture.md
#	packages/mermaid/src/docs/syntax/timeline.md
#	packages/mermaid/src/docs/syntax/treeView.md
#	packages/mermaid/src/docs/syntax/wardley.md
#	packages/mermaid/src/docs/syntax/xyChart.md
#	packages/mermaid/src/rendering-util/rendering-elements/shapes/requirementBox.ts
#	packages/parser/CHANGELOG.md
#	packages/parser/package.json
#	packages/tiny/CHANGELOG.md
#	packages/tiny/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants