[Bug Report] 弹窗的modal-append-to-body 属性,无论为true还是false,它的遮罩层总是在父元素
Element UI version
1.2.5
OS/Browsers version
win7
Vue version
2.2.5
Reproduction Link
https://jsfiddle.net/api/post/library/pure/
Steps to reproduce
Dialog对话框 modal-append-to-body属性 官方文档说明:遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Dialog 的父元素上 默认值:true
按照文档所说,默认情况下遮罩层应该是在body元素上,但是实际情况为什么还是在父元素上。
对话框:
结果:

What is Expected?
modal-append-to-body默认或设置为true的时候,遮罩层是在body元素中
What is actually happening?
modal-append-to-body默认或设置后,遮罩层总是在dialog的父元素
重现链接无效。
@Leopoldthecoder 重现链接只是官方文档中的示例!。。问题主要是:默认的dialog对象框,遮罩层是在父元素上面的,而不是body。
.el-dialog__wrapper 不是遮罩层。遮罩层的类名是 .v-modal
@liyang0612 请问这个问题解决了吗? 我也同样的问题了。
我也遇到同样的问题。关注。
I have the same error (Element UI 1.4.0). Looks like the property modal-append-to-body has no effect.
@HaydenWoos @iamnewsea @d--j
Like I said, .el-dialog__wrapper is not the backdrop, it's just the container of Dialog. The real backdrop is .v-modal.
modal-append-to-body is false: https://jsfiddle.net/q69hsjgz/1/
modal-append-to-body is true: https://jsfiddle.net/q69hsjgz/2/
so "modal" of modal-append-to-body is the backdrop – ok.
That was not clear to me. I thought it was the whole thing. Backdrop + Dialog (and it's wrapper). And I thought that's the prop that I need to set so that I do not have zIndex problems where the dialog gets behind the modal backdrop (or other parts of the page with a higher zIndex than something up the chain of the Vue app).
Consider this fiddle: https://jsfiddle.net/hoq8L6wy/2/
If you open this dialog it will be (a) behind the <div id="sidebar" /> and (b) behind the modal backdrop since the <div id="app" /> has a zIndex defined (z-index: 1) and the dialog as child of #app cannot break out of this zIndex. This can only be solved by moving the dialog out of #app to the <body>.
See e.g. z-index on MDN
[...] The box also establishes a local stacking context in which its stack level is 0. This means that the z-indexes of descendants are not compared to the z-indexes of elements outside this element. [...]
I think it makes sense to not only move the backdrop to the <body> when modal-append-to-body is true but the dialog (or it's wrapper) also.
BTW: This would make nested modal dialogs possible, too.
@d--j Hopefully Dialog will have another append-to-body that moves the whole thing to body in the next major version. #6088