This commit is contained in:
Rizky 2023-10-25 00:15:57 +07:00
parent 806619aa85
commit 66a0f7036f
2 changed files with 11 additions and 8 deletions

View File

@ -7,6 +7,7 @@ export const indentHook = (
local: { tree: null | TreeMethods; render: () => void }
) => {
useEffect(() => {
p.ui.tree.rename_id = "";
if (p.ui.prevent_indent_hook) {
p.ui.prevent_indent_hook = false;
return;

View File

@ -1,6 +1,7 @@
import { NodeModel, RenderParams } from "@minoru/react-dnd-treeview";
import { EDGlobal, EdMeta } from "../../../../logic/ed-global";
import { useGlobal, useLocal } from "web-utils";
import { useEffect } from "react";
export const EdTreeName = ({
node,
@ -10,17 +11,18 @@ export const EdTreeName = ({
prm: RenderParams;
}) => {
const p = useGlobal(EDGlobal, "EDITOR");
const local = useLocal(
{
rename: "",
},
() => {
local.rename = item?.name || "";
}
);
const local = useLocal({
rename: "",
});
useEffect(() => {
local.rename = item?.name || "";
}, [p.ui.tree.rename_id]);
const item = node.data?.item;
const mitem = node.data?.mitem;
if (!item || !mitem) return <></>;
const isRenaming = p.ui.tree.rename_id === item.id;
return (
<div className="text-[14px] relative flex items-center cursor-pointer flex-1">