fix: update checklist when pressing enter on edit

This commit is contained in:
Henry
2025-12-18 22:00:25 +00:00
parent cca8a9d424
commit 2694498335

View File

@@ -187,7 +187,10 @@ export default function ChecklistItemRow({
disabled={viewOnly}
onChange={(e) => setTitle(e.target.value)}
// @ts-expect-error - valid event
onBlur={(e: Event) => commitTitle(e.target.innerHTML as string)}
onBlur={(e: Event) => {
const innerHTML = (e.target as HTMLElement).innerHTML;
commitTitle(innerHTML);
}}
className={twMerge(
"m-0 min-h-[20px] w-full p-0 text-sm leading-[20px] text-light-950 outline-none focus-visible:outline-none dark:text-dark-950",
viewOnly && "cursor-default",
@@ -197,7 +200,8 @@ export default function ChecklistItemRow({
if (viewOnly) return;
if (e.key === "Enter") {
e.preventDefault();
commitTitle(title);
const innerHTML = (e.currentTarget as HTMLElement).innerHTML;
commitTitle(innerHTML);
}
if (e.key === "Escape") {
e.preventDefault();