Skip to content

Commit

Permalink
Merge pull request #39675 from teneeto/fix/39601/auto-focus-on-edit-t…
Browse files Browse the repository at this point in the history
…ax-amount

fix autofocus on edit tax amount text input
  • Loading branch information
MonilBhavsar authored Apr 5, 2024
2 parents 3ee7004 + 16d9c5c commit b0a50cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pages/EditRequestTaxAmountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ type EditRequestTaxAmountPageProps = {

function EditRequestTaxAmountPage({defaultAmount, defaultTaxAmount, defaultCurrency, onSubmit}: EditRequestTaxAmountPageProps) {
const {translate} = useLocalize();
const textInput = useRef<BaseTextInputRef>(null);
const textInput = useRef<BaseTextInputRef | null>();

const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);

useFocusEffect(
useCallback(() => {
focusTimeoutRef.current = setTimeout(() => textInput.current && textInput.current.focus(), CONST.ANIMATED_TRANSITION);
focusTimeoutRef.current = setTimeout(() => textInput.current?.focus(), CONST.ANIMATED_TRANSITION);
return () => {
if (!focusTimeoutRef.current) {
return;
Expand All @@ -52,7 +52,7 @@ function EditRequestTaxAmountPage({defaultAmount, defaultTaxAmount, defaultCurre
currency={defaultCurrency}
amount={defaultAmount}
taxAmount={defaultTaxAmount}
ref={textInput}
ref={(e) => (textInput.current = e)}
isCurrencyPressable={false}
onSubmitButtonPress={onSubmit}
isEditing
Expand Down

0 comments on commit b0a50cb

Please sign in to comment.