From 19b1baa2ba6236fa4d0645a497296346ae42c18b Mon Sep 17 00:00:00 2001 From: Travis Clark Date: Wed, 17 Jan 2024 09:34:13 -0600 Subject: [PATCH] fix: OPTIC-353: Fix null errors when switching from task detail to settings (#1665) * fix: optic-353: fix null errors when switching from task detail to settings * null block children before state tree destroy * Update src/LabelStudio.js Co-authored-by: hlomzik * fix null block logic for children * commiting console to understand the difference between local and deployed * destroy annotaions first * use getRoot to find the selected annotation for video region * revert image selection * Update src/stores/AppStore.js Co-authored-by: Sergey * check if annotation store exists from root * allow no conditional assignment for while loop --------- Co-authored-by: hlomzik Co-authored-by: Sergey --- src/LabelStudio.js | 2 ++ src/regions/VideoRegion.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LabelStudio.js b/src/LabelStudio.js index f0f6c6fd5e..29541ec5b7 100644 --- a/src/LabelStudio.js +++ b/src/LabelStudio.js @@ -79,6 +79,8 @@ export class LabelStudio { }; const clearRenderedApp = () => { + if (!rootElement.childNodes?.length) return; + const childNodes = [...rootElement.childNodes]; // cleanDomAfterReact needs this key to be sure that cleaning affects only current react subtree const reactKey = findReactKey(childNodes[0]); diff --git a/src/regions/VideoRegion.js b/src/regions/VideoRegion.js index 231320c3f1..c8cda9e8da 100644 --- a/src/regions/VideoRegion.js +++ b/src/regions/VideoRegion.js @@ -1,4 +1,4 @@ -import { types } from 'mobx-state-tree'; +import { getRoot, types } from 'mobx-state-tree'; import { guidGenerator } from '../core/Helpers'; import { AreaMixin } from '../mixins/AreaMixin'; @@ -34,7 +34,7 @@ const Model = types }, get annotation() { - return self.object.annotation; + return getRoot(self)?.annotationStore?.selected; }, getShape() {