Skip to content

Commit bbbe423

Browse files
committed
Use mergeRefs
1 parent 33981a9 commit bbbe423

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/components/DatePicker/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import type {ForwardedRef} from 'react';
44
import {InteractionManager, View} from 'react-native';
55
import * as Expensicons from '@components/Icon/Expensicons';
66
import TextInput from '@components/TextInput';
7+
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
78
import useLocalize from '@hooks/useLocalize';
89
import useThemeStyles from '@hooks/useThemeStyles';
910
import useWindowDimensions from '@hooks/useWindowDimensions';
11+
import mergeRefs from '@libs/mergeRefs';
1012
import {setDraftValues} from '@userActions/FormActions';
1113
import CONST from '@src/CONST';
1214
import DatePickerModal from './DatePickerModal';
@@ -32,8 +34,7 @@ function DatePicker(
3234
autoFocus = false,
3335
shouldHideClearButton = false,
3436
}: DateInputWithPickerProps,
35-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
36-
ref: ForwardedRef<View>,
37+
ref: ForwardedRef<BaseTextInputRef>,
3738
) {
3839
const styles = useThemeStyles();
3940
const {windowHeight, windowWidth} = useWindowDimensions();
@@ -42,7 +43,7 @@ function DatePicker(
4243
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
4344
const [selectedDate, setSelectedDate] = useState(value || defaultValue || undefined);
4445
const [popoverPosition, setPopoverPosition] = useState({horizontal: 0, vertical: 0});
45-
const textInputRef = useRef<HTMLFormElement | null>(null);
46+
const textInputRef = useRef<BaseTextInputRef>(null);
4647
const anchorRef = useRef<View>(null);
4748
const [isInverted, setIsInverted] = useState(false);
4849
const isAutoFocused = useRef(false);
@@ -124,7 +125,7 @@ function DatePicker(
124125
style={styles.mv2}
125126
>
126127
<TextInput
127-
ref={textInputRef}
128+
ref={mergeRefs(ref, textInputRef)}
128129
inputID={inputID}
129130
forceActiveLabel
130131
icon={selectedDate ? null : Expensicons.Calendar}

0 commit comments

Comments
 (0)