Modal: consider supporting stacked modals
That is - modals that can be opened from modals. The current thinking is:
- we are very reluctant to support those as it is very, very bad UX
- "real life" sometimes "requires" those anyway....
Will try to resist us long as possible before implementing stacked modals, but let's have this issue to track interest / real-life usage scenarios.
I think it should be supported (for your record)
I use modal for yes/no confirmation dialogs. However, if stacked modals aren't supported this means you can't have 'normal' modals with data entry which then uses modal confirmation dialogs. I guess one could argue data entry in modals are a bad UX?
Yeh, I'm kind of resigning to the reality of many projects and bracing for supporting this... But won't get to it before we land datepicker.
Voice in the discussion: https://github.com/twbs/bootstrap/issues/20607#issuecomment-244127770
I also agree with @pkozlowski-opensource stacked modal aren't good from UX perspective. Also, we had huge number of problems in one of large SPA build in Angular 1. Where there were confirmation dialogs, terms dialogs on top of existing dialogs, which caused more complexity, especially when in a web app reload happens, it is difficult to maintain state for those. We totally scrappeed the idea of having functional templates in modal. only for confirmation dialogs etc.
Is there any plans to support backdrop position in between stacked modals? It turns that for each inner modal its backdrop doesn't cover previous modal.
There is some quick reproduction: http://plnkr.co/edit/FG03lIbHjzM9wAZMoLWL?p=preview
@pkozlowski-opensource If this is considered by the team to be "very, very bad UX," what is the suggested alternative when several closely associated components need to operate on the same data? Especially with data that's already loaded? @ViewChild and direct subcomponent access? Child routes (and the terrible API of having to have a singleton service to pass references to in-memory data)?
@pkozlowski-opensource As you already said, sometimes we need stacked modals anyway. What is the alternative approach suggested by you till the library support stacked modals ?
@pkozlowski-opensource is there any progress on this matter?
When opening a modal(2) within a modal(1) it doesn't apply a backdrop to modal 1
Not sure where you are at on this issue, but I agree multiple modals are needed. In my instance I'm working on an address component what when you click edit opens a modal (because the edit controls take up much more place than a read-only address displayed in the DOM), I don't want to limit the component to only working outside of modals. In fact, I find it frustrating looking over the documentation that you are building an alternative implementation of Bootstrap.js, but treat modals so entirely different. I don't understand why instead of using divs and modal classes, why we need to use templates and host it in a special tag somewhere in the modal. From what I can tell, none of your other controls are imposing a different design than the standard Bootstrap.
I can understand you wanting to do it a particular way for ease of use for what you consider the common design pattern, but I can't see the justification for eliminating my ability to stick my modals anywhere in my HTML DOM that I chose and open them anyway I please.
There is also a problem when the first modal has a scroll bar... when you open a stacked modal over the first one and close it, it becomes impossible to scroll the first one.
Reproduce here: http://plnkr.co/edit/ZGYAbyJXwn8IWqz4sme8?p=preview
- Open by clicking Launch demo
- Scroll down and click on the stacked button
- Close the small modal
- Try to scroll again, it won't work...
Any updates on this? I would like to have the first modal included in the backdrop when the second modal is opened.
Quick fix is to add the following style: Assuming the backdrops/modals are added correctly in the DOM
.modal-backdrop {
z-index:1050;
}
@Vx2gas, z-index helps to some extent (the second modal backdrop is shown now over the first modal), but it doesn't fix the issue with scrolling: http://plnkr.co/edit/3cISZTeEoqfb76KaC12z?p=preview
@dmitrysteblyuk, your right. Anyone got a fix for this?
@Vx2gas the issue was that NgbModalRef removes modal-open class from body on destroy (despite that the first modal is still open). I added for myself this quick fix
modalRef.result.catch(() => {})
.then(() => {
if (document.querySelector('body > .modal')) {
document.body.classList.add('modal-open');
}
});
It seems, adding z-index for modal backdrop and modal-open class for body fixes all the mentioned above issues. I tested only in browser platform though.
Anyone for a PR?
An alternative to stacking modals would be the ability to switch between modals.
I attempted to do this manually: have a child component emit an event when it has a modal open. The parent (with it's own modal) could close the parent modal when the child is open, and reopen the parent modal when the child closes. However, calling modalRef.close on the parent appears to detach all modal listeners. The child's modalRef.result.then never fires, so I can't emit an event when the child closes.
Looks like the windowCmptRef gets nullified on close (modal-ref.ts line 98), and windowCmptRef is what is responsible for subscribing to close events (modal-ref.ts line 54). Is it possible that all modals are sharing the same windowCmptRef? It gets assigned at (modal-stack.ts line 52).
Plunkr of the issue here.
Just to add my 2c, when you say:
it is very, very bad UX
Twitter themselves use stacked modals - try going to a tweet and clicking on the picture.