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) => { onKeyDown={(e) => {
e.stopPropagation(); e.stopPropagation();
if (e.key === "Enter" || e.key === "Escape") { if (e.key === "Enter" || e.key === "Escape") {
if (e.key === "Escape") { if (item.component?.id) {
local.rename = item.name; if (!confirm("Rename component?")) {
} else { p.ui.tree.rename_id = "";
item.name = local.rename; p.render();
return;
}
} }
p.ui.tree.rename_id = "";
p.render();
setTimeout(() => { setTimeout(() => {
const el = document.querySelector( if (e.key === "Escape") {
`.tree-${item.id}` local.rename = item.name;
) as HTMLInputElement; } else {
if (el) el.focus(); 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) => { onChange={(e) => {