mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
A cell unmounted in the same render it was mounted in has no cell ref yet, and a context can be hidden after an awaited request outlived it (Sentry FE-BX, FP, FN).
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
/**
|
|
* This mixin is for components that have the Context component as root element.
|
|
* It will make it easier to call the root context specific functions.
|
|
*/
|
|
export default {
|
|
methods: {
|
|
getRootContext() {
|
|
// Search in the refs
|
|
if (this.$refs.context) {
|
|
return this.$refs.context
|
|
}
|
|
|
|
// There is nothing left to show or hide once the component is unmounted,
|
|
// for example when a request it awaited finishes after it was closed.
|
|
if (this.$.isUnmounted) {
|
|
return null
|
|
}
|
|
|
|
throw new Error('Missing context ref in this component')
|
|
},
|
|
toggle(...args) {
|
|
const context = this.getRootContext()
|
|
context && context.toggle(...args)
|
|
},
|
|
toggleNextToMouse(...args) {
|
|
const context = this.getRootContext()
|
|
context && context.toggleNextToMouse(...args)
|
|
},
|
|
show(...args) {
|
|
const context = this.getRootContext()
|
|
context && context.show(...args)
|
|
},
|
|
showNextToMouse(...args) {
|
|
const context = this.getRootContext()
|
|
context && context.showNextToMouse(...args)
|
|
},
|
|
hide(...args) {
|
|
const context = this.getRootContext()
|
|
context && context.hide(...args)
|
|
},
|
|
getTeleportedElement() {
|
|
const context = this.getRootContext()
|
|
return context?.getTeleportedElement() ?? null
|
|
},
|
|
},
|
|
}
|