-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: set initial task title and description values from Onyx if present #19908
Changes from 4 commits
cc30403
18b6d64
de2a494
2530158
546850b
cb52bf5
eaab646
b89a14f
f3df108
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, {useRef} from 'react'; | ||
import React, {useEffect, useRef, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import PropTypes from 'prop-types'; | ||
|
@@ -20,15 +20,33 @@ const propTypes = { | |
/** Beta features list */ | ||
betas: PropTypes.arrayOf(PropTypes.string), | ||
|
||
/** Task title and description data */ | ||
task: PropTypes.shape({ | ||
title: PropTypes.string, | ||
description: PropTypes.string, | ||
}), | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
betas: [], | ||
task: {}, | ||
}; | ||
|
||
const NewTaskPage = (props) => { | ||
const inputRef = useRef(); | ||
const [taskTitle, setTaskTitle] = useState(props.task.title); | ||
const [taskDescription, setTaskDescription] = useState(props.task.description); | ||
|
||
useEffect(() => { | ||
if (taskTitle !== props.task.title) { | ||
setTaskTitle(props.task.title); | ||
} | ||
if (taskDescription !== props.task.description) { | ||
setTaskDescription(props.task.description); | ||
} | ||
}, [props.task, taskTitle, taskDescription]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think have taskTitle, taskDescription here causing the below issue I am unable to update the title value when coming back to new task page. Untitled.2.mp4There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the comparison from the |
||
|
||
/** | ||
* @param {Object} values - form input values passed by the Form component | ||
|
@@ -63,7 +81,7 @@ const NewTaskPage = (props) => { | |
> | ||
<HeaderWithCloseButton | ||
title={props.translate('newTaskPage.assignTask')} | ||
onCloseButtonPress={() => Navigation.dismissModal()} | ||
onCloseButtonPress={() => TaskUtils.dismissModalAndClearOutTaskInfo()} | ||
shouldShowBackButton | ||
onBackButtonPress={() => Navigation.goBack()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @akinwale On this page alone, kindly clear out the task There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abdulrahuman5196 Done. |
||
/> | ||
|
@@ -80,13 +98,16 @@ const NewTaskPage = (props) => { | |
ref={(el) => (inputRef.current = el)} | ||
inputID="taskTitle" | ||
label={props.translate('newTaskPage.title')} | ||
value={taskTitle} | ||
onChangeText={(text) => setTaskTitle(text)} | ||
/> | ||
</View> | ||
<View style={styles.mb5}> | ||
<TextInput | ||
inputID="taskDescription" | ||
defaultValue="" | ||
label={props.translate('newTaskPage.descriptionOptional')} | ||
value={taskDescription} | ||
onChangeText={(text) => setTaskDescription(text)} | ||
/> | ||
</View> | ||
</Form> | ||
|
@@ -103,6 +124,9 @@ export default compose( | |
betas: { | ||
key: ONYXKEYS.BETAS, | ||
}, | ||
task: { | ||
key: ONYXKEYS.TASK, | ||
}, | ||
}), | ||
withLocalize, | ||
)(NewTaskPage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to compare?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this since the
useEffect
call will run only once when the component mounts.