This commit is contained in:
Rizky 2023-10-21 11:28:24 +07:00
parent 76bf7ebf53
commit 9dc86db663
1 changed files with 41 additions and 23 deletions

View File

@ -61,7 +61,21 @@ const Renaming: FC<{
spellCheck={false}
onChange={(e) => {
local.newname = e.currentTarget.value;
let shouldReplace =
local.newname.includes("=>") || local.newname.includes("<=");
const target = e.currentTarget;
let position = target.selectionStart;
if (shouldReplace) {
local.newname = local.newname.replace("<=", "⇦");
local.newname = local.newname.replace("=>", "⇨");
}
local.render();
setTimeout(() => {
if (position && shouldReplace) target.selectionEnd = position - 1;
});
}}
onClick={(e) => {
e.stopPropagation();
}}
onFocus={(e) => {
e.currentTarget.select();
@ -71,7 +85,9 @@ const Renaming: FC<{
e.currentTarget.blur();
}
}}
onBlur={() => {
onBlur={(e) => {
setTimeout(() => {
if (document.activeElement !== e.currentTarget) {
doneRenaming();
if (isComponent) {
const comp = item.get("component");
@ -97,6 +113,8 @@ const Renaming: FC<{
});
}
}
}
}, 100);
}}
autoFocus
/>