Files
alamin-br 71e30fc7ee fix: don't throw when a grid cell or context is gone before it's cleaned up (#6957)
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).
2026-12-01 18:01:30 +01:00

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
},
},
}