Skip to content

Commit

Permalink
Merge pull request Expensify#38015 from Krishna2323/krishna2323/re/is…
Browse files Browse the repository at this point in the history
…sue/34394

fix: Room - Side panel does not close when clicking outside of panel.
  • Loading branch information
danieldoglas authored Mar 19, 2024
2 parents 8d0d571 + a5af583 commit 7d8cede
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function BaseModal(
avoidKeyboard = false,
children,
shouldUseCustomBackdrop = false,
onBackdropPress,
}: BaseModalProps,
ref: React.ForwardedRef<View>,
) {
Expand Down Expand Up @@ -117,7 +118,11 @@ function BaseModal(
return;
}

onClose();
if (onBackdropPress) {
onBackdropPress();
} else {
onClose();
}
};

const handleDismissModal = () => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type BaseModalProps = Partial<ModalProps> & {
/** Callback method fired when the user requests to close the modal */
onClose: () => void;

/** Function to call when the user presses on the modal backdrop */
onBackdropPress?: () => void;

/** State that determines whether to display the modal or not */
isVisible: boolean;

Expand Down
3 changes: 2 additions & 1 deletion src/components/ValuePicker/ValueSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import type {ValueSelectorModalProps} from './types';

function ValueSelectorModal({items = [], selectedItem, label = '', isVisible, onClose, onItemSelected, shouldShowTooltips = true}: ValueSelectorModalProps) {
function ValueSelectorModal({items = [], selectedItem, label = '', isVisible, onClose, onItemSelected, shouldShowTooltips = true, onBackdropPress}: ValueSelectorModalProps) {
const styles = useThemeStyles();

const sections = useMemo(
Expand All @@ -24,6 +24,7 @@ function ValueSelectorModal({items = [], selectedItem, label = '', isVisible, on
onModalHide={onClose}
hideModalContentWhileAnimating
useNativeDriver
onBackdropPress={onBackdropPress}
>
<ScreenWrapper
style={styles.pb0}
Expand Down
2 changes: 2 additions & 0 deletions src/components/ValuePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FormHelpMessage from '@components/FormHelpMessage';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import type {ValuePickerItem, ValuePickerProps} from './types';
import ValueSelectorModal from './ValueSelectorModal';
Expand Down Expand Up @@ -55,6 +56,7 @@ function ValuePicker({value, label, items, placeholder = '', errorText = '', onI
onClose={hidePickerModal}
onItemSelected={updateInput}
shouldShowTooltips={shouldShowTooltips}
onBackdropPress={Navigation.dismissModal}
/>
</View>
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/ValuePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type ValueSelectorModalProps = {
/** Function to call when the user closes the modal */
onClose?: () => void;

/** Function to call when the user presses on the modal backdrop */
onBackdropPress?: () => void;

/** Whether to show the tooltip text */
shouldShowTooltips?: boolean;
};
Expand Down

0 comments on commit 7d8cede

Please sign in to comment.