Should modal always be appened to document.body?
See original GitHub issueMy app consists of various sidebar / menubar with various z-index / position CSS parameters. When I use b-modal inside my component, it tries to render the dialog inside the div where the child component is located which might be buried under other div / scroll bars, etc.
It looks like I can fix this simply by moving the b-modal to document.body via mounted() hook on the component that’s hosting the dialog
mounted() {
document.body.appendChild(this.$refs.modal.$el);
},
My app now looks like this.
My question is, shouldn’t the modal always be moved to the body for it to be rendered as designed? (Or at least moved to body by default while allowing user to not move it if they so choose via b-modal option?)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:15 (9 by maintainers)
Top Results From Across the Web
How to create a React Modal (which is appended to <body ...
The fundamental problem here is that in React you're only allowed to mount component to its parent, which is not always the desired...
Read more >How to create a modal in Javascript | by Marvin Clerge
Modals can be an incredibly useful tool in building a website. ... Then append the child to the modal, and modal to the...
Read more >Modal
Modals are built with HTML, CSS, and JavaScript. They're positioned over everything else in the document and remove scroll from the <body> so...
Read more >react-modal documentation
Using a custom parent node. By default, the modal portal will be appended to the document's body. You can choose a different parent...
Read more >How to Create a Modal Window For Your Websites - YouTube
... to create a custom modal window for use on your websites using plain HTML, CSS & JavaScript. This is very easy to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@soichih the next release of BootstrapVue (next release after 2.0.0-rc.19) will be using PortalVue to render the modal appended to the
<body>
element, by default (and modals will always be rendered lazily by default).The issue with fix-positioned parent containers is documented in Bootstrap V4 (and V3) https://getbootstrap.com/docs/4.0/components/modal/#how-it-works:
Since Bootstrap-Vue is based on Boostrap V4.beta CSS, it inherits the issues associated with Boostrap V4.beta’s CSS.
Basically, place your modal (or
<b-modal>
) component outside of any fixed position containers.