Launching a modal inside a modal closes the parent
See original GitHub issueSimple enough. I’m trying to open a modal inside a modal. You could probably argue against the UI ramifications against this but in our use-case, it’s worked well in the past under standard Bootstrap.
When trying the following little test harness you’ll click the button and whole thing closes.
let v = new Vue({
template: `
<b-modal id="visible_modal" title="visible modal" visible>
<b-btn v-b-modal.modal1>Launch sub modal</b-btn>
<b-modal id="modal1" title="Sub-modal!">
<p class="my-4">Hello from sub-modal!</p>
</b-modal>
</b-modal>
`,
})
v.$mount()
document.body.appendChild(v.$el)
This probably something to do with the events because if you set the child to be visible from the start, it displays fine.
let v = new Vue({
template: `
<b-modal id="visible_modal" title="visible modal" visible>
<b-btn v-b-modal.modal1>Launch sub modal</b-btn>
<b-modal id="modal1" title="Sub-modal!" visible>
<p class="my-4">Hello from sub-modal!</p>
</b-modal>
</b-modal>
`,
})
v.$mount()
document.body.appendChild(v.$el)
I’ve tried hooking on a almost every option to try and see if that fixes it but I just don’t know enough about the event chains here to what what they’re doing (or why).
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Bootstrap Modal inside modal closes parent modal
Working on bootstrap modal here i'm trying to add modal inside another modal in html as well. Is there a way using jquery...
Read more ><Modal/> Component - React-Bootstrap
Modals are unmounted when closed. ... Modal's "trap" focus in them, ensuring the keyboard navigation cycles through the modal, ... Launch demo modal....
Read more >How to get a React Bootstrap Modal to open and close using a ...
How to get a React Bootstrap Modal to open and close using a button of your choice in a parent component. I was...
Read more >React Modal component - Material UI - MUI
The modal component provides a solid foundation for creating dialogs, popovers, lightboxes, or whatever else.
Read more >Modal - Buefy
A modal with a component. When you want to close the Modal, call the 'close' method — this.$parent.close() — from the injected component....
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
I think we may have an option in mind to support opening modals over modals (unlike native Bootstrap V4), by keeping track of how many modals are open at the same time. Although the backdrop would appear darker each time a new modal is opened over another modal. (backdrops over backdrops)
We’re working on a bunch of improvements on various components for the next release.
I just did this. You have to capture the hide event on the parent vue object and preventDefault - as well as manually removing the modal-open class on the body on the child show event.