From 42f95cc741d7da8c64d572bb2f167c3822587d7f Mon Sep 17 00:00:00 2001 From: David Matejka Date: Fri, 24 May 2024 11:15:14 +0200 Subject: [PATCH] fix(react-dataview): fix handling custom subtrees inside dataview --- .../src/internal/helpers/staticAnalyzer.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-dataview/src/internal/helpers/staticAnalyzer.tsx b/packages/react-dataview/src/internal/helpers/staticAnalyzer.tsx index 66db4549e..63d520707 100644 --- a/packages/react-dataview/src/internal/helpers/staticAnalyzer.tsx +++ b/packages/react-dataview/src/internal/helpers/staticAnalyzer.tsx @@ -27,7 +27,7 @@ export const collectStaticInfo = (props: DataViewProps, env: Environment): DataV const createDataViewReactNode = (props: DataViewProps, env: Environment) => { const selectionState = props.initialSelection && typeof props.initialSelection !== 'function' ? props.initialSelection : {} const envWithSelectionState = env.withExtension(dataViewSelectionEnvironmentExtension, selectionState) - const entityListSubTree = {props.children} + const entityListSubTree = {props.children} return [entityListSubTree, envWithSelectionState] as const } @@ -39,7 +39,11 @@ const getQueryField = (props: DataViewProps, env: Environment) => { const [node, envWithSelectionState] = createDataViewReactNode(props, env) const markerTreeGenerator = new MarkerTreeGenerator(node, envWithSelectionState) const markerTree = markerTreeGenerator.generate() - const marker = Array.from(markerTree.subTrees.values())[0] + const placeholder = markerTree.placeholdersByAliases.get('__dataview_static') + if (!placeholder) { + throw new Error() + } + const marker = markerTree.subTrees.get(placeholder) if (!(marker instanceof EntityListSubTreeMarker)) { throw new Error() }