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

[docs-infra] Dark mode not persisting after switching from light mode #41874

Open
twassim1234 opened this issue Apr 12, 2024 · 8 comments
Open
Assignees
Labels
scope: docs-infra Specific to the docs-infra product

Comments

@twassim1234
Copy link

twassim1234 commented Apr 12, 2024

Steps to reproduce

Link to live example: (required)

Steps:
1.Navigate to the website in light mode.
2.Switch to dark mode.
3.Note the appearance in dark mode.
4.Refresh the page or navigate to another page within the website.

Current behavior

After switching from light mode to dark mode, the website briefly displays in light mode before switching back to dark mode.

daark.mp4

Expected behavior

The website should consistently remain in dark mode after the user has selected it, regardless of previous light mode usage.

Context

This issue affects the user experience of the website, particularly for users who prefer dark mode for extended periods. Consistent dark mode usage is expected for better accessibility and visual comfort.

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: MUI, dark mode, light mode, bug, behavior, environment, reproducible

@twassim1234 twassim1234 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 12, 2024
@danilo-leal danilo-leal changed the title Dark mode not persisting after switching from light mode [docs-infra] Dark mode not persisting after switching from light mode Apr 12, 2024
@danilo-leal danilo-leal added the scope: docs-infra Specific to the docs-infra product label Apr 12, 2024
@danilo-leal
Copy link
Contributor

Hey @twassim1234, thanks for the issue! Can you try to reproduce this problem somehow? I can't reproduce it myself. From the issue description, it seems you intended to attach a video, but it apparently didn't go through. That would be helpful.

@danilo-leal danilo-leal added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 12, 2024
@twassim1234
Copy link
Author

twassim1234 commented Apr 12, 2024

Hey @twassim1234, thanks for the issue! Can you try to reproduce this problem somehow? I can't reproduce it myself. From the issue description, it seems you intended to attach a video, but it apparently didn't go through. That would be helpful.

I add another video and now it's clear

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Apr 12, 2024
@alexfauquette
Copy link
Member

The rendering is done with 4 steps:

  1. Render light mode
  2. Add space for the tabbed code blocks
  3. Add the tab state and the code associated
  4. Style all the code blocks

Screenshot from 2024-04-15 16-11-46
Screenshot from 2024-04-15 16-11-58
Screenshot from 2024-04-15 16-12-15
Screenshot from 2024-04-15 16-12-23

@CelestialWorthy
Copy link

I've successfully reproduced the bug in my browser. In the video, you can see that the first attempt showed the bug mentioned , while the second attempt worked as expected. This confirms the existence of the bug.

Overview.-.Material.UI.-.Brave.2024-04-15.15-07-10.mp4

@twassim1234
Copy link
Author

I've successfully reproduced the bug in my browser. In the video, you can see that the first attempt showed the bug mentioned , while the second attempt worked as expected. This confirms the existence of the bug.

i think there is nothing changed

@CelestialWorthy
Copy link

I've successfully reproduced the bug in my browser. In the video, you can see that the first attempt showed the bug mentioned , while the second attempt worked as expected. This confirms the existence of the bug.

i think there is nothing changed

Could you please explain more what do you mean by nothing changed ? I jus t wanted to show that the bug does indeed happen but not all the time.

@mnajdova
Copy link
Member

We are aware of this issue, we can avoid it once all docs is migrated to use CSS variables. For example, at this moment this is done on the landing page: https://mui.com (if you refresh there is no flickering there), but it is not done in the docs pages. We have a guide on how you can avoid this in your apps in https://mui.com/material-ui/experimental-api/css-theme-variables/overview/ guide.

@mnajdova mnajdova removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 18, 2024
@twassim1234
Copy link
Author

We are aware of this issue, we can avoid it once all docs is migrated to use CSS variables. For example, at this moment this is done on the landing page: https://mui.com (if you refresh there is no flickering there), but it is not done in the docs pages. We have a guide on how you can avoid this in your apps in https://mui.com/material-ui/experimental-api/css-theme-variables/overview/ guide.

To facilitate the process, would you be open to providing some guidance or examples on how we can implement this effectively in the docs pages? Perhaps we could collaborate on improving the documentation together. Additionally, if there are any specific challenges or roadblocks you've encountered in implementing CSS variables in the docs, feel free to share, and we can work through them together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

No branches or pull requests

6 participants