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 } local: { tree: null | TreeMethods; render: () => void }
) => { ) => {
useEffect(() => { useEffect(() => {
p.ui.tree.rename_id = "";
if (p.ui.prevent_indent_hook) { if (p.ui.prevent_indent_hook) {
p.ui.prevent_indent_hook = false; p.ui.prevent_indent_hook = false;
return; return;

View File

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