wip fix rename component

This commit is contained in:
Rizky 2024-01-29 10:42:22 +07:00
parent 67f11cbbb0
commit 284fedc5c4
1 changed files with 21 additions and 12 deletions

View File

@ -85,20 +85,29 @@ export const EdTreeName = ({
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter" || e.key === "Escape") {
if (e.key === "Escape") {
local.rename = item.name;
} else {
item.name = local.rename;
if (item.component?.id) {
if (!confirm("Rename component?")) {
p.ui.tree.rename_id = "";
p.render();
return;
}
}
p.ui.tree.rename_id = "";
p.render();
setTimeout(() => {
const el = document.querySelector(
`.tree-${item.id}`
) as HTMLInputElement;
if (el) el.focus();
});
if (e.key === "Escape") {
local.rename = item.name;
} else {
item.name = local.rename;
}
p.ui.tree.rename_id = "";
p.render();
setTimeout(() => {
const el = document.querySelector(
`.tree-${item.id}`
) as HTMLInputElement;
if (el) el.focus();
});
}, 50);
}
}}
onChange={(e) => {