Skip to content

Commit

Permalink
Merge pull request #55197 from truph01/fix/54572
Browse files Browse the repository at this point in the history
  • Loading branch information
flodnv authored Jan 15, 2025
2 parents e4f0d89 + 480d061 commit 80fc026
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/PushRowWithModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useRef, useState} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -34,6 +34,9 @@ type PushRowWithModalProps = {

/** The ID of the input that should be reset when the value changes */
stateInputIDToReset?: string;

/** Callback to call when the picker modal is dismissed */
onBlur?: () => void;
};

function PushRowWithModal({
Expand All @@ -47,10 +50,14 @@ function PushRowWithModal({
errorText,
onInputChange = () => {},
stateInputIDToReset,
onBlur = () => {},
}: PushRowWithModalProps) {
const [isModalVisible, setIsModalVisible] = useState(false);

const shouldBlurOnCloseRef = useRef(true);
const handleModalClose = () => {
if (shouldBlurOnCloseRef.current) {
onBlur?.();
}
setIsModalVisible(false);
};

Expand All @@ -60,7 +67,7 @@ function PushRowWithModal({

const handleOptionChange = (optionValue: string) => {
onInputChange(optionValue);

shouldBlurOnCloseRef.current = false;
if (stateInputIDToReset) {
onInputChange('', stateInputIDToReset);
}
Expand Down

0 comments on commit 80fc026

Please sign in to comment.