From d402f9c15e909c7aa834af87145015ea5e647dda Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Mon, 23 Oct 2023 13:10:18 +0200 Subject: [PATCH 1/4] Add FormProvider in NewTaskTitlePage --- src/pages/tasks/NewTaskTitlePage.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/tasks/NewTaskTitlePage.js b/src/pages/tasks/NewTaskTitlePage.js index 62eb1da4872a..2a8d776eaefd 100644 --- a/src/pages/tasks/NewTaskTitlePage.js +++ b/src/pages/tasks/NewTaskTitlePage.js @@ -10,12 +10,13 @@ import ScreenWrapper from '../../components/ScreenWrapper'; import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS'; import * as ErrorUtils from '../../libs/ErrorUtils'; -import Form from '../../components/Form'; import TextInput from '../../components/TextInput'; import Permissions from '../../libs/Permissions'; import ROUTES from '../../ROUTES'; import * as Task from '../../libs/actions/Task'; import CONST from '../../CONST'; +import FormProvider from '../../components/Form/FormProvider'; +import InputWrapper from '../../components/Form/InputWrapper'; const propTypes = { /** Beta features list */ @@ -85,7 +86,7 @@ function NewTaskTitlePage(props) { shouldShowBackButton onBackButtonPress={() => Navigation.goBack(ROUTES.NEW_TASK)} /> -
+ ); } From d7ffb4717798771d53f3a193633bfd3ffb0bc8e7 Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:16:05 +0200 Subject: [PATCH 2/4] fix ref assignment --- src/pages/tasks/NewTaskTitlePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/tasks/NewTaskTitlePage.js b/src/pages/tasks/NewTaskTitlePage.js index 2a8d776eaefd..ac4cc69bd716 100644 --- a/src/pages/tasks/NewTaskTitlePage.js +++ b/src/pages/tasks/NewTaskTitlePage.js @@ -99,7 +99,7 @@ function NewTaskTitlePage(props) { InputComponent={TextInput} accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} defaultValue={props.task.title} - ref={(el) => (inputRef.current = el)} + ref={inputRef} inputID="taskTitle" label={props.translate('task.title')} accessibilityLabel={props.translate('task.title')} From 284f8e2547bec7ce37aeefc30c23da30ddca0840 Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:05:07 +0200 Subject: [PATCH 3/4] pass correct forwardedRef types --- src/components/Form/InputWrapper.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Form/InputWrapper.js b/src/components/Form/InputWrapper.js index 43064b5a6690..576af712beaa 100644 --- a/src/components/Form/InputWrapper.js +++ b/src/components/Form/InputWrapper.js @@ -1,12 +1,13 @@ import React, {forwardRef, useContext} from 'react'; import PropTypes from 'prop-types'; import FormContext from './FormContext'; +import refPropTypes from '../refPropTypes'; const propTypes = { InputComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]).isRequired, inputID: PropTypes.string.isRequired, valueType: PropTypes.string, - forwardedRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({current: PropTypes.instanceOf(React.Component)})]), + forwardedRef: refPropTypes, }; const defaultProps = { From 055d5dad061705e5e45d138afbdcf537053e3bd4 Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Mon, 30 Oct 2023 11:59:42 +0100 Subject: [PATCH 4/4] fix prettier and lint --- src/components/Form/InputWrapper.js | 2 +- src/pages/tasks/NewTaskTitlePage.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Form/InputWrapper.js b/src/components/Form/InputWrapper.js index 2f7ca50eccf9..b2e6f4477e89 100644 --- a/src/components/Form/InputWrapper.js +++ b/src/components/Form/InputWrapper.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React, {forwardRef, useContext} from 'react'; +import refPropTypes from '@components/refPropTypes'; import FormContext from './FormContext'; -import refPropTypes from '../refPropTypes'; const propTypes = { InputComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]).isRequired, diff --git a/src/pages/tasks/NewTaskTitlePage.js b/src/pages/tasks/NewTaskTitlePage.js index 6229a8f1252e..e7be9a239e5d 100644 --- a/src/pages/tasks/NewTaskTitlePage.js +++ b/src/pages/tasks/NewTaskTitlePage.js @@ -2,7 +2,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; -import Form from '@components/Form'; +import FormProvider from '@components/Form/FormProvider'; +import InputWrapperWithRef from '@components/Form/InputWrapper'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import TextInput from '@components/TextInput'; @@ -88,7 +89,7 @@ function NewTaskTitlePage(props) { enabledWhenOffline >