-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat: Allow adding newlines in description for tasks #19377
Changes from all commits
fce3fb6
55e8358
2ba07d8
3ec8704
2defd1d
361b998
fd07c8a
77a899f
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, {useCallback, useRef} from 'react'; | ||
import React, {useCallback, useEffect, useRef, useState} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
|
@@ -48,6 +48,17 @@ function TaskDescriptionPage(props) { | |
|
||
const inputRef = useRef(null); | ||
|
||
// Same as NewtaskDescriptionPage, use the selection to place the cursor correctly if there is prior text | ||
const [selection, setSelection] = useState({start: 0, end: 0}); | ||
|
||
// eslint-disable-next-line rulesdir/prefer-early-return | ||
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. Why disabled? 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 didn't think doing an early return here made much sense. It would've been 3 additional lines of code |
||
useEffect(() => { | ||
if (props.task.report && props.task.report.description) { | ||
const length = props.task.report.description.length; | ||
setSelection({start: length, end: length}); | ||
} | ||
}, [props.task.report]); | ||
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. Should have been a custom hook maybe. We try to follow the DRY principle. 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. Just saw these comments, sorry. Yeah, this would probably work but I'll be removing it anyway due to the React Native iOS bug with the selection prop. |
||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
|
@@ -69,6 +80,13 @@ function TaskDescriptionPage(props) { | |
label={props.translate('newTaskPage.descriptionOptional')} | ||
defaultValue={(props.task.report && props.task.report.description) || ''} | ||
ref={(el) => (inputRef.current = el)} | ||
autoGrowHeight | ||
containerStyles={[styles.autoGrowHeightMultilineInput]} | ||
textAlignVertical="top" | ||
selection={selection} | ||
onSelectionChange={(e) => { | ||
setSelection(e.nativeEvent.selection); | ||
}} | ||
/> | ||
</View> | ||
</Form> | ||
|
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.
Who knows what this page might use in the future or if it will continue to exist at all. Referencing it here does not add anything.
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.
Added this comment to provide some additional context since they were all task-related and the files were modified in the same commit.