Skip to content

fix(theme-mermaid): re-render diagrams when tabs become visible#11814

Open
saudademjj wants to merge 1 commit intofacebook:mainfrom
saudademjj:saudademjj/fix-mermaid-tabs-rerender
Open

fix(theme-mermaid): re-render diagrams when tabs become visible#11814
saudademjj wants to merge 1 commit intofacebook:mainfrom
saudademjj:saudademjj/fix-mermaid-tabs-rerender

Conversation

@saudademjj
Copy link
Copy Markdown

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Closes #8357.

Mermaid diagrams inside non-lazy tabs can render while their tabpanel is still hidden. When that happens, opening the second tab can show an incomplete diagram with missing arrows.

This PR re-renders a Mermaid diagram when its surrounding tabpanel becomes visible, and extracts the existing tab-visibility observer into a shared hook so the behavior can be reused outside code blocks.

Test Plan

  • added a regression test for a Mermaid block rendered inside a hidden tabpanel that becomes visible
  • ran yarn test packages/docusaurus-theme-mermaid/src/theme/Mermaid/__tests__/index.test.tsx --runInBand
  • ran yarn build:website:fast

Test links

Related issues/PRs

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Mar 19, 2026

Hi @saudademjj!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 6d72ed9
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69bb934850ed7f0008fb9e8d
😎 Deploy Preview https://deploy-preview-11814--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Mar 19, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mermaid in tabs. The arrows are not displayed in the second tab

1 participant