From 784aded48116e6d7cc70c5eff0d9796168df7bdf Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Fri, 8 Mar 2024 14:00:32 +0530 Subject: [PATCH] fix: Hold Request - Keyboard is up but the field is not focused with error message showing. Signed-off-by: Krishna Gupta --- src/pages/iou/HoldReasonPage.tsx | 4 +++- src/pages/settings/ExitSurvey/ExitSurveyResponsePage.tsx | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index 0e3df33358c0..4ff7f16e78ff 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -8,6 +8,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; +import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -36,6 +37,7 @@ type HoldReasonPageProps = { function HoldReasonPage({route}: HoldReasonPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const {inputCallbackRef} = useAutoFocusInput(); const {transactionID, reportID, backTo} = route.params; @@ -86,7 +88,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) { defaultValue={undefined} label={translate('iou.reason')} accessibilityLabel={translate('iou.reason')} - autoFocus + ref={inputCallbackRef} /> diff --git a/src/pages/settings/ExitSurvey/ExitSurveyResponsePage.tsx b/src/pages/settings/ExitSurvey/ExitSurveyResponsePage.tsx index c43ef8dd9320..611db1a77baa 100644 --- a/src/pages/settings/ExitSurvey/ExitSurveyResponsePage.tsx +++ b/src/pages/settings/ExitSurvey/ExitSurveyResponsePage.tsx @@ -8,6 +8,7 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; +import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; @@ -43,6 +44,7 @@ function ExitSurveyResponsePage({draftResponse, route, navigation}: ExitSurveyRe const {keyboardHeight} = useKeyboardState(); const {windowHeight} = useWindowDimensions(); const {top: safeAreaInsetsTop} = useSafeAreaInsets(); + const {inputCallbackRef} = useAutoFocusInput(); const {reason, backTo} = route.params; const {isOffline} = useNetwork({ @@ -132,6 +134,7 @@ function ExitSurveyResponsePage({draftResponse, route, navigation}: ExitSurveyRe return; } updateMultilineInputRange(el); + inputCallbackRef(el); }} containerStyles={[baseResponseInputContainerStyle, StyleUtils.getMaximumHeight(responseInputMaxHeight)]} shouldSaveDraft