mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +00:00
[Navigation Tree] Race condition on checking document readystate (#3430)
* checking if state is already ready, as this is a subcomponent, that could be the case * optimizing readystate checks
This commit is contained in:
@ -265,11 +265,7 @@ export default {
|
|||||||
async mounted() {
|
async mounted() {
|
||||||
|
|
||||||
// only reliable way to get final tree top margin
|
// only reliable way to get final tree top margin
|
||||||
document.onreadystatechange = () => {
|
this.readyStateCheck();
|
||||||
if (document.readyState === "complete") {
|
|
||||||
this.mainTreeTopMargin = this.getElementStyleValue(this.$refs.mainTree, 'marginTop');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.backwardsCompatibilityCheck();
|
this.backwardsCompatibilityCheck();
|
||||||
|
|
||||||
@ -323,8 +319,21 @@ export default {
|
|||||||
destroyed() {
|
destroyed() {
|
||||||
window.removeEventListener('resize', this.handleWindowResize);
|
window.removeEventListener('resize', this.handleWindowResize);
|
||||||
this.stopObservingAncestors();
|
this.stopObservingAncestors();
|
||||||
|
document.removeEventListener('readystatechange', this.setTreeTopMargin);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
readyStateCheck() {
|
||||||
|
if (document.readyState !== 'complete') {
|
||||||
|
document.addEventListener('readystatechange', this.setTreeTopMargin);
|
||||||
|
} else {
|
||||||
|
this.setTreeTopMargin();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setTreeTopMargin() {
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
this.mainTreeTopMargin = this.getElementStyleValue(this.$refs.mainTree, 'marginTop');
|
||||||
|
}
|
||||||
|
},
|
||||||
updateVisibleItems() {
|
updateVisibleItems() {
|
||||||
if (this.updatingView) {
|
if (this.updatingView) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,13 +122,7 @@ export default {
|
|||||||
let objectComposition = this.openmct.composition.get(this.node.object);
|
let objectComposition = this.openmct.composition.get(this.node.object);
|
||||||
|
|
||||||
// only reliable way to get final item height
|
// only reliable way to get final item height
|
||||||
document.onreadystatechange = () => {
|
this.readyStateCheck();
|
||||||
if (document.readyState === "complete") {
|
|
||||||
if (this.shouldEmitHeight) {
|
|
||||||
this.$emit('emittedHeight', this.$el.offsetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.domainObject = this.node.object;
|
this.domainObject = this.node.object;
|
||||||
let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => {
|
let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => {
|
||||||
@ -144,8 +138,21 @@ export default {
|
|||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.openmct.router.off('change:path', this.highlightIfNavigated);
|
this.openmct.router.off('change:path', this.highlightIfNavigated);
|
||||||
|
document.removeEventListener('readystatechange', this.emitHeight);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
readyStateCheck() {
|
||||||
|
if (document.readyState !== 'complete') {
|
||||||
|
document.addEventListener('readystatechange', this.emitHeight);
|
||||||
|
} else {
|
||||||
|
this.emitHeight();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emitHeight() {
|
||||||
|
if (this.shouldEmitHeight && document.readyState === 'complete') {
|
||||||
|
this.$emit('emittedHeight', this.$el.offsetHeight);
|
||||||
|
}
|
||||||
|
},
|
||||||
buildPathString(parentPath) {
|
buildPathString(parentPath) {
|
||||||
return [parentPath, this.openmct.objects.makeKeyString(this.node.object.identifier)].join('/');
|
return [parentPath, this.openmct.objects.makeKeyString(this.node.object.identifier)].join('/');
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user