diff --git a/src/components/Header/Header.scss b/src/components/Header/Header.scss index a9763cfce..fa39efec1 100644 --- a/src/components/Header/Header.scss +++ b/src/components/Header/Header.scss @@ -32,7 +32,7 @@ } &__new-todo { - width: 100%; + width: 85%; padding: 16px 16px 16px 60px; font-size: 24px; diff --git a/src/components/TodoList/TodoItem/TodoItem.scss b/src/components/TodoList/TodoItem/TodoItem.scss index 4576af434..a5bc4a982 100644 --- a/src/components/TodoList/TodoItem/TodoItem.scss +++ b/src/components/TodoList/TodoItem/TodoItem.scss @@ -71,7 +71,7 @@ } &__title-field { - width: 100%; + width: 93.8%; padding: 11px 14px; font-size: inherit; diff --git a/src/components/TodoList/TodoItem/TodoItem.tsx b/src/components/TodoList/TodoItem/TodoItem.tsx index 74a105b19..97244513f 100644 --- a/src/components/TodoList/TodoItem/TodoItem.tsx +++ b/src/components/TodoList/TodoItem/TodoItem.tsx @@ -11,6 +11,7 @@ type Props = { }; export const TodoItem: React.FC = ({ todo }) => { + const { id, title, completed } = todo; const [selectedTodo, setSelectedTodo] = useState(null); const [query, setQuery] = useState(''); const [isEscaped, setIsEscaped] = useState(false); @@ -31,7 +32,7 @@ export const TodoItem: React.FC = ({ todo }) => { setSelectedTodo(todos.find(t => t.title === selectedTodoTitle)); } - function handleSubmitForm(id: number, newTitle: string) { + function handleSubmitForm(currId: number, newTitle: string) { if (isEscaped) { setIsEscaped(false); @@ -39,10 +40,10 @@ export const TodoItem: React.FC = ({ todo }) => { } if (!newTitle.trim()) { - removeTodo(id); + removeTodo(currId); } - renameTodo(id, newTitle); + renameTodo(currId, newTitle); setSelectedTodo(null); } @@ -62,14 +63,14 @@ export const TodoItem: React.FC = ({ todo }) => { }, [selectedTodo]); return ( -
+
@@ -77,9 +78,9 @@ export const TodoItem: React.FC = ({ todo }) => {
{ ev.preventDefault(); - handleSubmitForm(todo.id, query); + handleSubmitForm(id, query); }} - onBlur={() => handleSubmitForm(todo.id, query)} + onBlur={() => handleSubmitForm(id, query)} > = ({ todo }) => { className="todo__title" onDoubleClick={handleSelectTodo} > - {todo.title} + {title}