From 07de3f8362d89bcee9959ed6da417b76bf42e4db Mon Sep 17 00:00:00 2001 From: Volodymyr Vynnyk Date: Tue, 5 Nov 2024 13:23:42 +0200 Subject: [PATCH] fix final ver --- src/components/Header/Header.tsx | 8 +++++++- src/components/TodoItem/TodoItem.tsx | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index ce74f1197..09dece5b7 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -23,12 +23,17 @@ export const Header: FC = () => { ); }; - const handleSubmit = (event: React.FormEvent) => { + const handleSubmit = ( + event: // eslint-disable-next-line @typescript-eslint/indent + React.FormEvent | React.FocusEvent, + ) => { event.preventDefault(); const newTitle = title.trim(); if (!newTitle) { + setTitle(''); + return; } @@ -72,6 +77,7 @@ export const Header: FC = () => { value={title} onChange={event => setTitle(event.target.value)} disabled={isSubmitting} + onBlur={handleSubmit} /> diff --git a/src/components/TodoItem/TodoItem.tsx b/src/components/TodoItem/TodoItem.tsx index ea568fde9..d1b3600e9 100644 --- a/src/components/TodoItem/TodoItem.tsx +++ b/src/components/TodoItem/TodoItem.tsx @@ -38,8 +38,6 @@ export const TodoItem: React.FC = ({ todo }) => { return; } - setEditedTitle(validEditedTitle); - try { dispatch({ type: 'update',