Skip to content
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

[Form Provider Refactor] NewTaskTitlePage #30167

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Form/InputWrapper.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import PropTypes from 'prop-types';
import React, {forwardRef, useContext} from 'react';
import refPropTypes from '@components/refPropTypes';
import FormContext from './FormContext';

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 = {
Expand Down
10 changes: 6 additions & 4 deletions src/pages/tasks/NewTaskTitlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,7 +80,7 @@ function NewTaskTitlePage(props) {
shouldShowBackButton
onBackButtonPress={() => Navigation.goBack(ROUTES.NEW_TASK)}
/>
<Form
<FormProvider
formID={ONYXKEYS.FORMS.NEW_TASK_FORM}
submitButtonText={props.translate('common.next')}
style={[styles.mh5, styles.flexGrow1]}
Expand All @@ -88,7 +89,8 @@ function NewTaskTitlePage(props) {
enabledWhenOffline
>
<View style={styles.mb5}>
<TextInput
<InputWrapperWithRef
InputComponent={TextInput}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
defaultValue={props.task.title}
ref={inputCallbackRef}
Expand All @@ -97,7 +99,7 @@ function NewTaskTitlePage(props) {
accessibilityLabel={props.translate('task.title')}
/>
</View>
</Form>
</FormProvider>
</ScreenWrapper>
);
}
Expand Down
Loading