Skip to content

Conversation

@effie-ms
Copy link
Contributor

@effie-ms effie-ms commented Oct 31, 2025

Which Jira task is linked to this PR?

https://lifi.atlassian.net/browse/LF-16412

Why was it implemented this way?

_UPD:
Using the example provided in #583, just removing setMode() will not be sufficient.
The problem is that MUI's mode switcher (setMode()) always overwrites global html attributes, no matter what properties are set when defining the theme: when we define colorSchemeSelector: 'class' (or any other attribute) in createTheme (from MUI), it is always attached to the html node.

MUI's ThemeProvider has a property colorSchemeNode which allows to attach the color scheme attribute to a certain node (not only to global html), which theoretically could scope the mode only within widget's container, but instead it just duplicates the attributes, setting them to both global html node and that specified node.

So setting the node in this form still does not resolve the problem.

<div id="lifi-widget-custom-root">
      <MuiThemeProvider
        ...
        colorSchemeNode={document.getElementById('lifi-widget-custom-root') as Element}
      >
        {children}
      </MuiThemeProvider>
</div>
Screen.Recording.2025-11-07.at.15.26.48.mov

Instead, conditionally attaching widget to shadow root: https://mui.com/material-ui/customization/shadow-dom/

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.

@effie-ms effie-ms changed the title fix: add disableGlobalThemeManagement config fix: prevent overriding global theme from widget Oct 31, 2025
@effie-ms effie-ms self-assigned this Oct 31, 2025
@effie-ms effie-ms marked this pull request as ready for review October 31, 2025 13:14
@github-actions
Copy link

Hey! This is your new endpoint: https://173f0e87.widget-lf16412.pages.dev

@effie-ms effie-ms requested a review from chybisov October 31, 2025 13:58
@effie-ms effie-ms marked this pull request as draft November 7, 2025 14:33
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Hey! This is your new endpoint: https://04d5fd7f.widget-lf16412.pages.dev

@github-actions
Copy link

Hey! This is your new endpoint: https://84575238.widget-lf16412.pages.dev

@effie-ms
Copy link
Contributor Author

We have observed performance issues with wrapping the widget into shadow root, so closing it for now.

Decided to proceed with already existing workaround: setting the theme via config: hiding the theme switcher in the widget UI (HiddenUI.Appearance) and passing the theme mode into config (appearance: 'light' | 'dark' | 'system'). Then the theme can be switched externally, and the widget will just adapt to the change.

Docs:
https://docs.li.fi/widget/customize-widget#appearance
https://docs.li.fi/widget/customize-widget#hidden-ui-elements

@effie-ms effie-ms closed this Nov 21, 2025
@effie-ms effie-ms deleted the lf-16412 branch November 21, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants