Skip to content

Commit c0368bd

Browse files
authored
fix: Remove drawer rendering into shadow DOM (#113)
1 parent 66bdd69 commit c0368bd

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/bundles/remoteTutorDrawer.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,21 @@ import { MathJaxContext } from "better-react-mathjax"
1717
const init = (opts: RemoteTutorDrawerProps) => {
1818
const container = document.createElement("div")
1919
document.body.appendChild(container)
20-
const shadowContainer = container.attachShadow({ mode: "open" })
21-
const shadowRootEl = document.createElement("div")
22-
shadowRootEl.id = "smoot-chat-drawer-root"
23-
shadowContainer.append(shadowRootEl)
24-
// See https://mui.com/material-ui/customization/shadow-dom/
25-
// Ensure style tags are rendered in shadow root
20+
container.id = "smoot-chat-drawer-root"
21+
2622
const cache = createCache({
2723
key: "css",
2824
prepend: true,
29-
container: shadowContainer,
25+
container: container,
3026
})
3127
const theme = createTheme({
3228
components: {
33-
// Ensure modals, etc, are rendered in shadow root
34-
MuiPopover: { defaultProps: { container: shadowRootEl } },
35-
MuiPopper: { defaultProps: { container: shadowRootEl } },
36-
MuiModal: { defaultProps: { container: shadowRootEl } },
29+
MuiPopover: { defaultProps: { container: container } },
30+
MuiPopper: { defaultProps: { container: container } },
31+
MuiModal: { defaultProps: { container: container } },
3732
},
3833
})
39-
createRoot(shadowRootEl).render(
34+
createRoot(container).render(
4035
<CacheProvider value={cache}>
4136
<ThemeProvider theme={theme}>
4237
<MathJaxContext>
@@ -48,7 +43,6 @@ const init = (opts: RemoteTutorDrawerProps) => {
4843
)
4944

5045
// Ensure mathjax context menu is rendered above the drawer
51-
// NOTE: must be done in regular DOM, not hte shadowdom.
5246
// Mathjax context menu is appended to end of body.
5347
const style = document.createElement("style")
5448
style.textContent = `

0 commit comments

Comments
 (0)