wip fix open tree
This commit is contained in:
parent
abab7f0113
commit
607c034254
|
|
@ -5,7 +5,7 @@ import {
|
|||
PlaceholderRender,
|
||||
TreeMethods,
|
||||
} from "@minoru/react-dnd-treeview";
|
||||
import { FC } from "react";
|
||||
import { FC, useEffect } from "react";
|
||||
import { useGlobal, useLocal } from "web-utils";
|
||||
import { EDGlobal, EdMeta, active } from "../../logic/ed-global";
|
||||
import { DEPTH_WIDTH } from "./node/item/indent";
|
||||
|
|
@ -40,6 +40,24 @@ export const EdTreeBody = () => {
|
|||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (local.tree) {
|
||||
let parents = [];
|
||||
if (active.comp_id) {
|
||||
parents = p.comp.list[local.comp_id].scope[active.item_id].p;
|
||||
} else {
|
||||
parents = p.page.scope[active.item_id].p;
|
||||
}
|
||||
if (parents.length === 1) {
|
||||
local.tree.open(
|
||||
tree.filter((e) => e.parent === "root").map((e) => e.id)
|
||||
);
|
||||
} else {
|
||||
local.tree.open(parents);
|
||||
}
|
||||
}
|
||||
}, [active.item_id, active.comp_id]);
|
||||
|
||||
if (tree.length === 0)
|
||||
return (
|
||||
<div className="flex py-[100px] select-none justify-center flex-1">
|
||||
|
|
|
|||
Loading…
Reference in New Issue