fix(popover): __placeableEnabled not correct

This commit is contained in:
07akioni 2020-10-04 02:23:46 +08:00
parent fdf2c74b92
commit f1cea30192
2 changed files with 43 additions and 35 deletions

View File

@ -2,6 +2,7 @@ import {
h,
ref,
computed,
watch,
Fragment,
createTextVNode
} from 'vue'
@ -52,38 +53,6 @@ export default {
NPopover: this
}
},
setup (props) {
// setup show
const controlledShowRef = computed(() => props.show)
const uncontrolledShowRef = ref(props.defaultShow)
const mergedShowWithoutDisabledRef = useMergedState(
controlledShowRef,
uncontrolledShowRef
)
const mergedShowRef = computed(() => {
return props.disabled ? false : mergedShowWithoutDisabledRef.value
})
// setup show-arrow
const compatibleShowArrowRef = useCompitable(props, [
'arrow',
'showArrow'
])
return {
isMounted: useIsMounted(),
// if to show popover body
uncontrolledShow: uncontrolledShowRef,
mergedShow: mergedShowRef,
compatibleShowArrow: compatibleShowArrowRef
}
},
data () {
return {
showTimerId: null,
hideTimerId: null,
triggerVNode: null,
bodyInstance: null
}
},
props: {
show: {
type: Boolean,
@ -191,6 +160,43 @@ export default {
default: undefined
}
},
setup (props) {
// setup show
const controlledShowRef = computed(() => props.show)
const uncontrolledShowRef = ref(props.defaultShow)
const mergedShowWithoutDisabledRef = useMergedState(
controlledShowRef,
uncontrolledShowRef
)
const mergedShowRef = computed(() => {
return props.disabled ? false : mergedShowWithoutDisabledRef.value
})
// setup show-arrow
const compatibleShowArrowRef = useCompitable(props, [
'arrow',
'showArrow'
])
watch(mergedShowRef, value => {
if (props.showWatcher) {
props.showWatcher(value)
}
})
return {
isMounted: useIsMounted(),
// if to show popover body
uncontrolledShow: uncontrolledShowRef,
mergedShow: mergedShowRef,
compatibleShowArrow: compatibleShowArrowRef
}
},
data () {
return {
showTimerId: null,
hideTimerId: null,
triggerVNode: null,
bodyInstance: null
}
},
methods: {
syncPosition () {
if (this.bodyInstance) {

View File

@ -106,6 +106,11 @@ export default {
__placeableEnabled: this.show
}
},
watch: {
show (value) {
if (value) this.__placeableEnabled = true
}
},
created () {
this.NPopover.bodyInstance = this
},
@ -196,9 +201,6 @@ export default {
h(Transition, {
name: 'popover-body-transition',
appear: this.NPopover.isMounted,
onEnter: () => {
this.__placeableEnabled = true
},
onAfterLeave: () => {
this.__placeableEnabled = false
}