question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Launching a modal inside a modal closes the parent

See original GitHub issue

Simple 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:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tmorehousecommented, Nov 6, 2018

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.

2reactions
sonicmolsoncommented, Aug 23, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found