mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 22:17: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:
parent
87a45de05b
commit
6923f17645
@ -265,11 +265,7 @@ export default {
|
||||
async mounted() {
|
||||
|
||||
// only reliable way to get final tree top margin
|
||||
document.onreadystatechange = () => {
|
||||
if (document.readyState === "complete") {
|
||||
this.mainTreeTopMargin = this.getElementStyleValue(this.$refs.mainTree, 'marginTop');
|
||||
}
|
||||
};
|
||||
this.readyStateCheck();
|
||||
|
||||
this.backwardsCompatibilityCheck();
|
||||
|
||||
@ -323,8 +319,21 @@ export default {
|
||||
destroyed() {
|
||||
window.removeEventListener('resize', this.handleWindowResize);
|
||||
this.stopObservingAncestors();
|
||||
document.removeEventListener('readystatechange', this.setTreeTopMargin);
|
||||
},
|
||||
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() {
|
||||
if (this.updatingView) {
|
||||
return;
|
||||
|
@ -122,13 +122,7 @@ export default {
|
||||
let objectComposition = this.openmct.composition.get(this.node.object);
|
||||
|
||||
// only reliable way to get final item height
|
||||
document.onreadystatechange = () => {
|
||||
if (document.readyState === "complete") {
|
||||
if (this.shouldEmitHeight) {
|
||||
this.$emit('emittedHeight', this.$el.offsetHeight);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.readyStateCheck();
|
||||
|
||||
this.domainObject = this.node.object;
|
||||
let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => {
|
||||
@ -144,8 +138,21 @@ export default {
|
||||
},
|
||||
destroyed() {
|
||||
this.openmct.router.off('change:path', this.highlightIfNavigated);
|
||||
document.removeEventListener('readystatechange', this.emitHeight);
|
||||
},
|
||||
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) {
|
||||
return [parentPath, this.openmct.objects.makeKeyString(this.node.object.identifier)].join('/');
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user