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

Rendering the library inside a shadow DOM? #974

Open
omerfaran opened this issue Aug 31, 2023 · 2 comments
Open

Rendering the library inside a shadow DOM? #974

omerfaran opened this issue Aug 31, 2023 · 2 comments

Comments

@omerfaran
Copy link

omerfaran commented Aug 31, 2023

Describe the bug
(Using version 5.4.2)

I'm rendering the library inside a shadow DOM, and updated my material UI theme to render portals, like in Mui docs (https://mui.com/material-ui/guides/shadow-dom/):

const theme = createTheme({
  components: {
    MuiPopover: {
      defaultProps: {
        container: shadowRootElement,
      },
    },
    MuiPopper: {
      defaultProps: {
        container: shadowRootElement,
      },
    },
    MuiModal: {
      defaultProps: {
        container: shadowRootElement,
      },
    },
  },
});

However, the dropdown of the library (which is Mui Autocomplete) completely loses its stylings, it just displays a text list with no container and no scroll. Maybe the library uses disablePortal set to true?
Is there a way to have the library work inside a shadow DOM?

Thanks in advance

To Reproduce
Wrap the library in a shadow DOM

Expected behavior
Have same stylings

@omerfaran
Copy link
Author

Alternatively is it possible to render your own Select/Autocompelte? I found this thread from 2019, but the attached link not working:
#109

Thanks

@omerfaran
Copy link
Author

What I found is that you can intercept each relevant component and force it to using the app's Mui theme that does have a reference to the shadow DOM, something like:

      settings: {
        ...MuiConfig.settings,
        renderField: (props) => (
          <WithTheme>
            {MuiConfig.settings.renderField(props)}
          </WithTheme>
        ),
      },

That way, even though React awesome query builder defines its own theme, you can come "in between" and force components back into your defined shadow DOM

Hope it helps anyone,
It's certainly not a bug of the app, just something to deal with

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

No branches or pull requests

1 participant