Skip to content

Commit ecf0ec2

Browse files
authored
Merge pull request #23342 from dukenv0307/fix/22078-after
Fix: The title field is cleared when the Confirm task button is pressed
2 parents a426cca + dea5c96 commit ecf0ec2

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/libs/actions/Task.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ function createTaskAndNavigate(parentReportID, title, description, assignee, ass
204204
{optimisticData, successData, failureData},
205205
);
206206

207-
clearOutTaskInfo();
208-
209207
Navigation.dismissModal(optimisticTaskReport.reportID);
210208
}
211209

src/pages/tasks/NewTaskPage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function NewTaskPage(props) {
6868
const [shareDestination, setShareDestination] = React.useState({});
6969
const [errorMessage, setErrorMessage] = React.useState('');
7070
const [parentReport, setParentReport] = React.useState({});
71+
const shouldClearOutTaskInfoOnUnmount = React.useRef(false);
7172

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

@@ -101,6 +102,16 @@ function NewTaskPage(props) {
101102
}
102103
}, [props]);
103104

105+
useEffect(
106+
() => () => {
107+
if (!shouldClearOutTaskInfoOnUnmount.current) {
108+
return;
109+
}
110+
Task.clearOutTaskInfo();
111+
},
112+
[],
113+
);
114+
104115
// On submit, we want to call the createTask function and wait to validate
105116
// the response
106117
function onSubmit() {
@@ -119,6 +130,7 @@ function NewTaskPage(props) {
119130
return;
120131
}
121132

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

src/pages/tasks/TaskDescriptionPage.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize
88
import Form from '../../components/Form';
99
import ONYXKEYS from '../../ONYXKEYS';
1010
import TextInput from '../../components/TextInput';
11+
import reportPropTypes from '../reportPropTypes';
1112
import styles from '../../styles/styles';
1213
import compose from '../../libs/compose';
13-
import reportPropTypes from '../reportPropTypes';
1414
import * as Task from '../../libs/actions/Task';
1515
import CONST from '../../CONST';
1616
import focusAndUpdateMultilineInputRange from '../../libs/focusAndUpdateMultilineInputRange';
@@ -21,19 +21,16 @@ const propTypes = {
2121
email: PropTypes.string.isRequired,
2222
}),
2323

24-
/** Task Report Info */
25-
task: PropTypes.shape({
26-
/** Title of the Task */
27-
report: reportPropTypes,
28-
}),
24+
/** The report currently being looked at */
25+
report: reportPropTypes,
2926

3027
/* Onyx Props */
3128
...withLocalizePropTypes,
3229
};
3330

3431
const defaultProps = {
3532
session: {},
36-
task: {},
33+
report: {},
3734
};
3835

3936
function TaskDescriptionPage(props) {
@@ -43,7 +40,7 @@ function TaskDescriptionPage(props) {
4340
(values) => {
4441
// Set the description of the report in the store and then call Task.editTaskReport
4542
// to update the description of the report on the server
46-
Task.editTaskAndNavigate(props.task.report, props.session.accountID, {description: values.description});
43+
Task.editTaskAndNavigate(props.report, props.session.accountID, {description: values.description});
4744
},
4845
[props],
4946
);
@@ -72,7 +69,7 @@ function TaskDescriptionPage(props) {
7269
name="description"
7370
label={props.translate('newTaskPage.descriptionOptional')}
7471
accessibilityLabel={props.translate('newTaskPage.descriptionOptional')}
75-
defaultValue={(props.task.report && props.task.report.description) || ''}
72+
defaultValue={(props.report && props.report.description) || ''}
7673
ref={(el) => (inputRef.current = el)}
7774
autoGrowHeight
7875
submitOnEnter
@@ -94,8 +91,8 @@ export default compose(
9491
session: {
9592
key: ONYXKEYS.SESSION,
9693
},
97-
task: {
98-
key: ONYXKEYS.TASK,
94+
report: {
95+
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`,
9996
},
10097
}),
10198
)(TaskDescriptionPage);

0 commit comments

Comments
 (0)