Skip to content

Commit 99ffa95

Browse files
nass600hlomzik
andauthored
fix: LEAP-2060: Dynamic choices are not displayed when Interactive View All FF is turned ON (#7468)
Co-authored-by: nass600 <nass600@users.noreply.github.com> Co-authored-by: hlomzik <hlomzik@users.noreply.github.com>
1 parent dc89b0d commit 99ffa95

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

web/libs/editor/src/mixins/DynamicChildrenMixin.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { getRoot, protect, types, unprotect } from "mobx-state-tree";
22
import ProcessAttrsMixin from "./ProcessAttrs";
33
import { parseValue } from "../utils/data";
4+
import { guidGenerator } from "../utils/unique";
5+
import { FF_DEV_3391 } from "../utils/feature-flags";
6+
import { ff } from "@humansignal/core";
47

58
const DynamicChildrenMixin = types
69
.model({})
@@ -12,11 +15,19 @@ const DynamicChildrenMixin = types
1215
}))
1316
.actions((self) => {
1417
const prepareDynamicChildrenData = (data, store, parent) => {
18+
// Right now with the FF on, we are traverseing the Tree in the store::initRoot and the
19+
// AnnotationStore::afterCreate which will generate duplicated children so we only need to
20+
// run this once, when the annotation store is not yet initialized
21+
if (ff.isActive(FF_DEV_3391) && store.annotationStore.initialized) return;
22+
1523
if (data && data.length) {
1624
for (const obj of data) {
25+
// No matter if using Interactive View mode or not, we add the ids for consistency
26+
const id = obj.id ?? guidGenerator();
1727
parent.children.push({
1828
type: self.defaultChildType,
1929
...obj,
30+
id,
2031
children: [],
2132
});
2233

@@ -51,9 +62,13 @@ const DynamicChildrenMixin = types
5162
// we may need to rewrite this, initRoot and the other related methods
5263
// (actually a lot of them) to work asynchronously as well
5364

54-
setTimeout(() => {
65+
if (ff.isActive(FF_DEV_3391)) {
5566
self.updateDynamicChildren(store);
56-
});
67+
} else {
68+
setTimeout(() => {
69+
self.updateDynamicChildren(store);
70+
});
71+
}
5772
},
5873

5974
updateDynamicChildren(store) {

0 commit comments

Comments
 (0)