Skip to content

Commit

Permalink
Merge pull request #22983 from dukenv0307/fix/22078
Browse files Browse the repository at this point in the history
fix: The title field is cleared when the Confirm task button is pressed
  • Loading branch information
robertjchen authored Jul 19, 2023
2 parents f225936 + edb5378 commit 2d2008a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ function createTaskAndNavigate(parentReportID, title, description, assignee, ass
{optimisticData, successData, failureData},
);

clearOutTaskInfo();

Navigation.dismissModal(optimisticTaskReport.reportID);
}

Expand Down
12 changes: 12 additions & 0 deletions src/pages/tasks/NewTaskPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function NewTaskPage(props) {
const [shareDestination, setShareDestination] = React.useState({});
const [errorMessage, setErrorMessage] = React.useState('');
const [parentReport, setParentReport] = React.useState({});
const shouldClearOutTaskInfoOnUnmount = React.useRef(false);

const isAllowedToCreateTask = useMemo(() => _.isEmpty(parentReport) || ReportUtils.isAllowedToComment(parentReport), [parentReport]);

Expand Down Expand Up @@ -101,6 +102,16 @@ function NewTaskPage(props) {
}
}, [props]);

useEffect(
() => () => {
if (!shouldClearOutTaskInfoOnUnmount.current) {
return;
}
Task.clearOutTaskInfo();
},
[],
);

// On submit, we want to call the createTask function and wait to validate
// the response
function onSubmit() {
Expand All @@ -119,6 +130,7 @@ function NewTaskPage(props) {
return;
}

shouldClearOutTaskInfoOnUnmount.current = true;
Task.createTaskAndNavigate(parentReport.reportID, props.task.title, props.task.description, props.task.assignee, props.task.assigneeAccountID);
}

Expand Down

0 comments on commit 2d2008a

Please sign in to comment.