Merge branch 'disjointed-popovers' into shigusegubu-vue3
* disjointed-popovers: fix errors in console pinned no longer needed popover stack
This commit is contained in:
commit
8d42b18de5
2 changed files with 22 additions and 31 deletions
|
@ -53,12 +53,13 @@ const Popover = {
|
||||||
// with popovers refusing to be hidden when user wants to interact with something in below popover
|
// with popovers refusing to be hidden when user wants to interact with something in below popover
|
||||||
lockReEntry: false,
|
lockReEntry: false,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
pinned: false,
|
|
||||||
styles: {},
|
styles: {},
|
||||||
oldSize: { width: 0, height: 0 },
|
oldSize: { width: 0, height: 0 },
|
||||||
scrollable: null,
|
scrollable: null,
|
||||||
// used to avoid blinking if hovered onto popover
|
// used to avoid blinking if hovered onto popover
|
||||||
graceTimeout: null
|
graceTimeout: null,
|
||||||
|
parentPopover: null,
|
||||||
|
childrenShown: new Set()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -200,9 +201,9 @@ const Popover = {
|
||||||
},
|
},
|
||||||
showPopover () {
|
showPopover () {
|
||||||
if (this.disabled) return
|
if (this.disabled) return
|
||||||
this.pinned = false
|
|
||||||
const wasHidden = this.hidden
|
const wasHidden = this.hidden
|
||||||
this.hidden = false
|
this.hidden = false
|
||||||
|
this.parentPopover && this.parentPopover.onChildPopoverState(this, true)
|
||||||
if (this.trigger === 'click' || this.stayOnClick) {
|
if (this.trigger === 'click' || this.stayOnClick) {
|
||||||
document.addEventListener('click', this.onClickOutside)
|
document.addEventListener('click', this.onClickOutside)
|
||||||
}
|
}
|
||||||
|
@ -217,6 +218,7 @@ const Popover = {
|
||||||
if (this.disabled) return
|
if (this.disabled) return
|
||||||
if (!this.hidden) this.$emit('close')
|
if (!this.hidden) this.$emit('close')
|
||||||
this.hidden = true
|
this.hidden = true
|
||||||
|
this.parentPopover && this.parentPopover.onChildPopoverState(this, false)
|
||||||
if (this.trigger === 'click') {
|
if (this.trigger === 'click') {
|
||||||
document.removeEventListener('click', this.onClickOutside)
|
document.removeEventListener('click', this.onClickOutside)
|
||||||
}
|
}
|
||||||
|
@ -232,7 +234,7 @@ const Popover = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseleave (e) {
|
onMouseleave (e) {
|
||||||
if (this.trigger === 'hover' && !this.pinned) {
|
if (this.trigger === 'hover' && this.childrenShown.size > 0) {
|
||||||
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -245,7 +247,7 @@ const Popover = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseleaveContent (e) {
|
onMouseleaveContent (e) {
|
||||||
if (this.trigger === 'hover' && !this.pinned) {
|
if (this.trigger === 'hover' && this.childrenShown.size === 0) {
|
||||||
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
this.graceTimeout = setTimeout(() => this.hidePopover(), 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -260,20 +262,24 @@ const Popover = {
|
||||||
},
|
},
|
||||||
onClickOutside (e) {
|
onClickOutside (e) {
|
||||||
if (this.hidden) return
|
if (this.hidden) return
|
||||||
if (this.$refs.content.contains(e.target)) return
|
if (this.$refs.content && this.$refs.content.contains(e.target)) return
|
||||||
if (this.$el.contains(e.target)) return
|
if (this.$el.contains(e.target)) return
|
||||||
|
if (this.childrenShown.size > 0) return
|
||||||
this.hidePopover()
|
this.hidePopover()
|
||||||
},
|
if (this.parentPopover) this.parentPopover.onClickOutside(e)
|
||||||
onClickContent (e) {
|
|
||||||
if (this.trigger === 'hover' && this.stayOnClick) {
|
|
||||||
this.pinned = true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onScroll (e) {
|
onScroll (e) {
|
||||||
this.updateStyles()
|
this.updateStyles()
|
||||||
},
|
},
|
||||||
onResize (e) {
|
onResize (e) {
|
||||||
this.updateStyles()
|
this.updateStyles()
|
||||||
|
},
|
||||||
|
onChildPopoverState (childRef, state) {
|
||||||
|
if (state) {
|
||||||
|
this.childrenShown.add(childRef)
|
||||||
|
} else {
|
||||||
|
this.childrenShown.delete(childRef)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updated () {
|
updated () {
|
||||||
|
@ -292,6 +298,11 @@ const Popover = {
|
||||||
this.$refs.trigger.closest('.mobile-notifications')
|
this.$refs.trigger.closest('.mobile-notifications')
|
||||||
if (!scrollable) scrollable = window
|
if (!scrollable) scrollable = window
|
||||||
this.scrollable = scrollable
|
this.scrollable = scrollable
|
||||||
|
let parent = this.$parent
|
||||||
|
while (parent && parent.$.type.name !== 'Popover') {
|
||||||
|
parent = parent.$parent
|
||||||
|
}
|
||||||
|
this.parentPopover = parent
|
||||||
},
|
},
|
||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
this.hidePopover()
|
this.hidePopover()
|
||||||
|
|
|
@ -28,15 +28,6 @@
|
||||||
class="popover-inner"
|
class="popover-inner"
|
||||||
:close="hidePopover"
|
:close="hidePopover"
|
||||||
/>
|
/>
|
||||||
<div
|
|
||||||
v-if="stayOnClick && pinned"
|
|
||||||
class="pinned-tooltip-icon popover popover-default"
|
|
||||||
>
|
|
||||||
<FAIcon
|
|
||||||
icon="thumbtack"
|
|
||||||
class="faint"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</teleport>
|
</teleport>
|
||||||
|
@ -61,17 +52,6 @@
|
||||||
box-shadow: var(--popupShadow);
|
box-shadow: var(--popupShadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pinned-tooltip-icon {
|
|
||||||
position: absolute;
|
|
||||||
top: -1em;
|
|
||||||
left: -1em;
|
|
||||||
width: 2em;
|
|
||||||
height: 2em;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popover-default {
|
.popover-default {
|
||||||
&:after {
|
&:after {
|
||||||
content: '';
|
content: '';
|
||||||
|
|
Loading…
Add table
Reference in a new issue