diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.js b/src/pages/tasks/TaskAssigneeSelectorModal.js index f8f567a7b913..7e5ab63bdddf 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.js +++ b/src/pages/tasks/TaskAssigneeSelectorModal.js @@ -17,9 +17,11 @@ import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize import compose from '../../libs/compose'; import personalDetailsPropType from '../personalDetailsPropType'; import reportPropTypes from '../reportPropTypes'; -import ROUTES from '../../ROUTES'; import * as ReportUtils from '../../libs/ReportUtils'; +import ROUTES from '../../ROUTES'; import * as Task from '../../libs/actions/Task'; +import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; +import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails'; const propTypes = { /** Beta features list */ @@ -194,10 +196,14 @@ function TaskAssigneeSelectorModal(props) { } }; + const isOpen = ReportUtils.isOpenTaskReport(props.task.report); + const canModifyTask = Task.canModifyTask(props.task.report, props.currentUserPersonalDetails.accountID); + const isTaskNonEditable = report && ReportUtils.isTaskReport(props.task.report) && (!canModifyTask || !isOpen); + return ( {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( - <> + (lodashGet(props.route.params, 'reportID') ? Navigation.dismissModal() : Navigation.goBack(ROUTES.NEW_TASK))} @@ -215,7 +221,7 @@ function TaskAssigneeSelectorModal(props) { safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} /> - + )} ); @@ -227,6 +233,7 @@ TaskAssigneeSelectorModal.defaultProps = defaultProps; export default compose( withLocalize, + withCurrentUserPersonalDetails, withOnyx({ reports: { key: ONYXKEYS.COLLECTION.REPORT, diff --git a/src/pages/tasks/TaskDescriptionPage.js b/src/pages/tasks/TaskDescriptionPage.js index 0ccd3821571e..382e8d80d4ad 100644 --- a/src/pages/tasks/TaskDescriptionPage.js +++ b/src/pages/tasks/TaskDescriptionPage.js @@ -12,11 +12,14 @@ import reportPropTypes from '../reportPropTypes'; import styles from '../../styles/styles'; import compose from '../../libs/compose'; import * as Task from '../../libs/actions/Task'; +import * as ReportUtils from '../../libs/ReportUtils'; import CONST from '../../CONST'; import focusAndUpdateMultilineInputRange from '../../libs/focusAndUpdateMultilineInputRange'; import * as Browser from '../../libs/Browser'; -import * as ReportUtils from '../../libs/ReportUtils'; import Navigation from '../../libs/Navigation/Navigation'; +import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; +import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails'; +import withReportOrNotFound from '../home/report/withReportOrNotFound'; const propTypes = { /** Current user session */ @@ -55,37 +58,54 @@ function TaskDescriptionPage(props) { } const inputRef = useRef(null); + const isOpen = ReportUtils.isOpenTaskReport(props.report); + const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID); + const isTaskNonEditable = ReportUtils.isTaskReport(props.report) && (!canModifyTask || !isOpen); + return ( focusAndUpdateMultilineInputRange(inputRef.current)} shouldEnableMaxHeight > - -
- - (inputRef.current = el)} - autoGrowHeight - submitOnEnter={!Browser.isMobile()} - containerStyles={[styles.autoGrowHeightMultilineInput]} - textAlignVertical="top" - /> - -
+ {({didScreenTransitionEnd}) => ( + + +
+ + { + // if we wrap the page with FullPageNotFoundView we need to explicitly handle focusing on text input + if (!el) { + return; + } + if (!inputRef.current && didScreenTransitionEnd) { + focusAndUpdateMultilineInputRange(el); + } + inputRef.current = el; + }} + autoGrowHeight + submitOnEnter={!Browser.isMobile()} + containerStyles={[styles.autoGrowHeightMultilineInput]} + textAlignVertical="top" + /> + +
+
+ )}
); } @@ -95,6 +115,8 @@ TaskDescriptionPage.defaultProps = defaultProps; export default compose( withLocalize, + withCurrentUserPersonalDetails, + withReportOrNotFound, withOnyx({ session: { key: ONYXKEYS.SESSION, diff --git a/src/pages/tasks/TaskTitlePage.js b/src/pages/tasks/TaskTitlePage.js index 9e3edd370264..9a7a36a1e119 100644 --- a/src/pages/tasks/TaskTitlePage.js +++ b/src/pages/tasks/TaskTitlePage.js @@ -13,9 +13,12 @@ import styles from '../../styles/styles'; import reportPropTypes from '../reportPropTypes'; import compose from '../../libs/compose'; import * as Task from '../../libs/actions/Task'; -import CONST from '../../CONST'; import * as ReportUtils from '../../libs/ReportUtils'; +import CONST from '../../CONST'; import Navigation from '../../libs/Navigation/Navigation'; +import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; +import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails'; +import withReportOrNotFound from '../home/report/withReportOrNotFound'; const propTypes = { /** The report currently being looked at */ @@ -67,6 +70,9 @@ function TaskTitlePage(props) { } const inputRef = useRef(null); + const isOpen = ReportUtils.isOpenTaskReport(props.report); + const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID); + const isTaskNonEditable = ReportUtils.isTaskReport(props.report) && (!canModifyTask || !isOpen); return ( inputRef.current && inputRef.current.focus()} shouldEnableMaxHeight > - -
- - (inputRef.current = el)} - /> - -
+ {({didScreenTransitionEnd}) => ( + + +
+ + { + if (!el) return; + if (!inputRef.current && didScreenTransitionEnd) { + el.focus(); + } + inputRef.current = el; + }} + /> + +
+
+ )}
); } @@ -104,6 +120,8 @@ TaskTitlePage.defaultProps = defaultProps; export default compose( withLocalize, + withCurrentUserPersonalDetails, + withReportOrNotFound, withOnyx({ session: { key: ONYXKEYS.SESSION,