Skip to content

Commit

Permalink
Merge pull request #56347 from FitseTLT/fix-showing-error-on-per-diem…
Browse files Browse the repository at this point in the history
…-quantity

Fix - Per diem - Quantity field shows error after selecting a subrate
  • Loading branch information
amyevans authored Feb 12, 2025
2 parents 82afd4e + 5cd0fdc commit becb704
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/pages/iou/request/step/IOURequestStepSubrate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useNavigation} from '@react-navigation/native';
import React, {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import ConfirmModal from '@components/ConfirmModal';
Expand All @@ -10,11 +10,11 @@ import type {FormOnyxValues} from '@components/Form/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Expensicons from '@components/Icon/Expensicons';
import type BaseModalProps from '@components/Modal/types';
import type {AnimatedTextInputRef} from '@components/RNTextInput';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
import ValuePicker from '@components/ValuePicker';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -76,7 +76,7 @@ function IOURequestStepSubrate({
const navigation = useNavigation();
const isFocused = navigation.isFocused();
const {translate} = useLocalize();
const {inputCallbackRef} = useAutoFocusInput();
const textInputRef = useRef<AnimatedTextInputRef>(null);
const parsedIndex = parseInt(pageIndex, 10);
const selectedDestination = transaction?.comment?.customUnit?.customUnitRateID;
const allSubrates = transaction?.comment?.customUnit?.subRates ?? [];
Expand Down Expand Up @@ -229,13 +229,18 @@ function IOURequestStepSubrate({
value={subrateValue}
defaultValue={currentSubrate?.id}
items={validOptions}
onValueChange={(value) => setSubrateValue(value as string)}
onValueChange={(value) => {
setSubrateValue(value as string);
InteractionManager.runAfterInteractions(() => {
textInputRef.current?.focus();
});
}}
/>
</View>
<InputWrapperWithRef
InputComponent={TextInput}
inputID={`quantity${pageIndex}`}
ref={inputCallbackRef}
ref={textInputRef}
containerStyles={[styles.mt4]}
label={translate('iou.quantity')}
value={quantityValue}
Expand Down

0 comments on commit becb704

Please sign in to comment.