when using iframes, portals mount at root of document instead of root of iframe #9252
Closed
1 task done
Labels
Milestone
TL;DR I'm trying to render a
Select
element inside of an iframe, but when I do this, theMenuItem
components inside render in completely the wrong place. Looking into the code, I noticed that the portal was actually mounting at the root of the document instead of the iframe.Expected Behavior
<Select>
with<MenuItem>
s inside an iframe.Current Behavior
<Select>
with<MenuItem>
s inside an iframe.Steps to Reproduce (for bugs)
See above.
CodeSandbox: https://codesandbox.io/s/73nnlv78wq
Note: in the codesandbox, the iframe doesn't contain material-ui styling. This is because the jss needs to be injected into the iframe explictly, as well as
<MuiThemeProvider>
. This is a different, unrelated issue and so I didn't take the time to implement that here.Context
In my app, I have an iframe in which I would like to use material-ui components. This bug is preventing me from using anything that uses portals under the hood.
I dug into the source a bit, and I have identified this as the issue: https://github.com/mui-org/material-ui/blob/v1-beta/src/internal/Portal.js#L47.
Since this uses document directly, it ends up ignoring the context of my iframe and instead attaches the portal to the parent root. It would be nice if there was some way to manipulate this, maybe through context or props.
Your Environment
The text was updated successfully, but these errors were encountered: