Skip to content

Commit e1f2e00

Browse files
committed
fix create-api single & visible prop logic
1 parent 54232bf commit e1f2e00

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/common/helpers/create-api-component.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function createAPIComponent(Vue, Component, events = [], single =
1616
}
1717
let instanceSingle = options
1818
if (typeof options === 'object') {
19-
instanceSingle = !!options.single
19+
instanceSingle = options.single
2020
delete options.single
2121
}
2222

@@ -28,7 +28,17 @@ export default function createAPIComponent(Vue, Component, events = [], single =
2828
}
2929
if (instanceSingle && singleComponent) {
3030
singleInstance.updateRenderData(data, renderFn)
31+
// visibility mixin watch visible should not hide
32+
singleComponent._createAPI_reuse = true
3133
singleInstance.$forceUpdate()
34+
const oldVisible = singleComponent.visible
35+
singleComponent.$nextTick(() => {
36+
singleComponent._createAPI_reuse = false
37+
// prop visible true -> to
38+
if (oldVisible && singleComponent.visible) {
39+
singleComponent.show()
40+
}
41+
})
3242
// singleComponent.show && singleComponent.show()
3343
return singleComponent
3444
}
@@ -75,7 +85,7 @@ export default function createAPIComponent(Vue, Component, events = [], single =
7585
processEvents()
7686

7787
if (typeof renderFn !== 'function' && single === undefined) {
78-
single = !!renderFn
88+
single = renderFn
7989
renderFn = null
8090
}
8191
// to get Vue options

src/common/mixins/visibility.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export default {
2525
},
2626
mounted() {
2727
this.$watch('visible', (newVal, oldVal) => {
28-
newVal ? this.show() : oldVal && this.hide()
28+
if (newVal) {
29+
this.show()
30+
} else if (oldVal && !this._createAPI_reuse) {
31+
this.hide()
32+
}
2933
}, {
3034
immediate: true
3135
})

0 commit comments

Comments
 (0)