Skip to content

fix: keep Mermaid styles scoped to each diagram - #116

Closed
anabaarbosa wants to merge 2 commits into
mainfrom
fix/mermaid-scoped-styles
Closed

anabaarbosa wants to merge 2 commits into
mainfrom
fix/mermaid-scoped-styles

Conversation

@anabaarbosa

Copy link
Copy Markdown
Contributor

What

  • Render each Mermaid diagram with a unique id and keep that id in the SVG instead of stripping #mermaid-id from the output.
  • Default flowcharts to htmlLabels: false.
  • Rebuild dist.

Why

Stripping the id turned Mermaid's theme CSS into global rules. Selectors such as .label text, span, p { color: #142032 }, .cluster span, p { color: #000 } and svg { font-family: ... } leaked into the whole page. On the Developer Portal, 128 of 400 sampled article elements (p, code, strong, span) on Refresh token flow for headless implementations were rendered with the diagram colors instead of the article colors.

With the id kept, Mermaid emits #mermaid-<uuid> .label text, #mermaid-<uuid> span, ... and nothing leaks (verified on Help Center: 0 affected elements).

Using a unique id also allows more than one diagram per page without the second one overriding the first.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['release-no', 'release-auto', 'release-patch', 'release-minor', 'release-major']

@anabaarbosa anabaarbosa closed this Oct 5, 2026
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.

1 participant