From 9d7f46907f8dc6beb5460faf6200d7e4c17c7d87 Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Sun, 3 Jan 2021 15:54:32 -0600 Subject: [PATCH] fix(MyTasks): update task entry name when updating name through TaskDetails --- frontend/src/MyTasks/TaskEntry.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/MyTasks/TaskEntry.tsx b/frontend/src/MyTasks/TaskEntry.tsx index 7c6a7c7..01b0923 100644 --- a/frontend/src/MyTasks/TaskEntry.tsx +++ b/frontend/src/MyTasks/TaskEntry.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import styled, { css } from 'styled-components/macro'; import dayjs from 'dayjs'; import { CheckCircleOutline, CheckCircle, Cross, Briefcase, ChevronRight } from 'shared/icons'; @@ -303,6 +303,9 @@ const TaskEntry: React.FC = ({ const leftRow = window.innerWidth - RIGHT_ROW_WIDTH; const [focused, setFocused] = useState(autoFocus); const [name, setName] = useState(initialName); + useEffect(() => { + setName(initialName); + }, [initialName]); const $projects = useRef(null); const $dueDate = useRef(null); const $nameInput = useRef(null); @@ -332,10 +335,9 @@ const TaskEntry: React.FC = ({ }} onChange={e => setName(e.currentTarget.value)} wrap="off" + value={name} rows={1} - > - {name} - + /> onTaskDetails()}>