Material UI React Modal Dialog on custom container

て烟熏妆下的殇ゞ 提交于 2020-04-11 05:39:19

问题


I'm trying to show a dialog that's only partially modal, as in modal over a specific element, so that the user can still interact with other parts of the application. The docs specify that a dialog component has a container and a fullscreen property. I've tried setting the container property to the div element I want to render the dialog and backdrop on. But without any luck.

I want to modal to only be modal on this part of the application as shown in the image.

Here are the docs for the Dialog component https://material-ui-next.com/api/dialog/

Any help would be greatly appreciated!


回答1:


I ran into the same issue. It's not documented in the <Dialog /> section, but if you look at the API docs for the <Modal /> component there is a prop called 'container' and since Dialog is really just a modified Modal component you're good to use the same props...

<Dialog
    container={() => document.getElementById('parentCo')}>
</Dialog>


来源:https://stackoverflow.com/questions/49236761/material-ui-react-modal-dialog-on-custom-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!