mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
fix: detached content's disappearance in modal or drawer isn't delayed
This commit is contained in:
parent
aa977a6dc4
commit
0e08fd9d20
@ -1,3 +1,9 @@
|
||||
function cleanUp (content, target) {
|
||||
if (content && target && target.contains(content)) {
|
||||
target.removeChild(content)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'NBasePortal',
|
||||
inject: {
|
||||
@ -36,8 +42,17 @@ export default {
|
||||
},
|
||||
beforeDestroy () {
|
||||
const target = this.transferTarget()
|
||||
if (target && target.contains(this.$el)) {
|
||||
target.removeChild(this.$el)
|
||||
const content = this.$el
|
||||
/**
|
||||
* Since content may be detached in modal, waiting animation done is
|
||||
* important. A more elegant solution is needed.
|
||||
*/
|
||||
if (this.NModal || this.NDrawer) {
|
||||
setTimeout(() => {
|
||||
cleanUp(content, target)
|
||||
}, 300)
|
||||
} else {
|
||||
cleanUp(content, target)
|
||||
}
|
||||
},
|
||||
data () {
|
||||
|
@ -1,5 +1,11 @@
|
||||
import withapp from './withapp'
|
||||
|
||||
function cleanUp (content, target) {
|
||||
if (content && target && target.contains(content)) {
|
||||
target.removeChild(content)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach $refs.contentContainer to detachTarget
|
||||
*
|
||||
@ -93,8 +99,16 @@ export default {
|
||||
if (this.syntheticDetachable) {
|
||||
const content = this.getDetachContent()
|
||||
const target = this.getDetachTarget()
|
||||
if (content && target && target.contains(content)) {
|
||||
this.getDetachTarget().removeChild(content)
|
||||
/**
|
||||
* Since content may be detached in modal, waiting animation done is
|
||||
* important. A more elegant solution is needed.
|
||||
*/
|
||||
if (this.NModal || this.NDrawer) {
|
||||
setTimeout(() => {
|
||||
cleanUp(content, target)
|
||||
}, 300)
|
||||
} else {
|
||||
cleanUp(content, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user