Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In "sandbox" mode, the background of the iframe is not responsive to dark mode #5034

Open
bartkamphorst opened this issue Nov 13, 2023 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@bartkamphorst
Copy link

Description

Dear mermaid team, over at gollum, we're busy implementing dark mode. We run mermaid with securityLevel: 'sandbox' and noticed that the diagrams in the resulting iframe are not automatically responsive to enabling/disabling dark mode (in System settings). We have worked around this by adding an event listener to (prefers-color-scheme: dark)' and re-rendering the diagram with the dark theme when dark mode is enabled. However, when we do, the background of the resulting iframe remains white. I would expect the background of the iframe to assume the background color of the surrounding page.

Steps to reproduce

Go to the Mermaid live editor and render the default diagram with the following settings:

{
  "theme": "dark",
  "securityLevel": "sandbox"
}

Screenshots

  • What happens when the theme is not specified:

Screenshot 2023-11-03 at 13 10 29

  • What happens when the dark theme is used:

Screenshot 2023-11-03 at 11 14 59

  • What we'd like to see happen:

Screenshot 2023-11-03 at 16 07 19

This last screenshot does reflect what happens when we set securityLevel: 'loose'.

Code Sample

No response

Setup

  • Mermaid version: 10.6.0
  • Browser and Version: Firefox 119.0.1

Suggested Solutions

This is not my expertise, so this may not be the best solution, but adding

<meta name="color-scheme" content="light dark">

to the <head> of the iframe resolves the issue in gollum.

I think the relevant code lives here in putIntoIFrame.

Additional Context

Thanks for considering this issue! Please let us know (@dometto @benjaminwil) if there's anything we can do to help resolve it.

@bartkamphorst bartkamphorst added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 13, 2023
@jgreywolf jgreywolf added include and removed include labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants