fix(MyTasks): update task entry name when updating name through TaskDetails

This commit is contained in:
Jordan Knott 2021-01-03 15:54:32 -06:00
parent dcf53b9077
commit 9d7f46907f

View File

@ -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 styled, { css } from 'styled-components/macro';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { CheckCircleOutline, CheckCircle, Cross, Briefcase, ChevronRight } from 'shared/icons'; import { CheckCircleOutline, CheckCircle, Cross, Briefcase, ChevronRight } from 'shared/icons';
@ -303,6 +303,9 @@ const TaskEntry: React.FC<TaskEntryProps> = ({
const leftRow = window.innerWidth - RIGHT_ROW_WIDTH; const leftRow = window.innerWidth - RIGHT_ROW_WIDTH;
const [focused, setFocused] = useState(autoFocus); const [focused, setFocused] = useState(autoFocus);
const [name, setName] = useState(initialName); const [name, setName] = useState(initialName);
useEffect(() => {
setName(initialName);
}, [initialName]);
const $projects = useRef<HTMLDivElement>(null); const $projects = useRef<HTMLDivElement>(null);
const $dueDate = useRef<HTMLDivElement>(null); const $dueDate = useRef<HTMLDivElement>(null);
const $nameInput = useRef<HTMLTextAreaElement>(null); const $nameInput = useRef<HTMLTextAreaElement>(null);
@ -332,10 +335,9 @@ const TaskEntry: React.FC<TaskEntryProps> = ({
}} }}
onChange={e => setName(e.currentTarget.value)} onChange={e => setName(e.currentTarget.value)}
wrap="off" wrap="off"
value={name}
rows={1} rows={1}
> />
{name}
</TaskNameInput>
</TaskName> </TaskName>
<TaskDetailsArea onClick={() => onTaskDetails()}> <TaskDetailsArea onClick={() => onTaskDetails()}>
<TaskDetailsButton> <TaskDetailsButton>