Skip to content

Commit 53cb725

Browse files
committed
Hide backdrop of YearPickerModal when it is displayed on top of a RHP
1 parent 862884d commit 53cb725

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/components/DatePicker/CalendarPicker/YearPickerModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ type YearPickerModalProps = {
1414
/** Whether the modal is visible */
1515
isVisible: boolean;
1616

17+
/** Whether the picker is displayed over RHP */
18+
isRHPVisible: boolean;
19+
1720
/** The list of years to render */
1821
years: CalendarPickerListItem[];
1922

@@ -27,7 +30,7 @@ type YearPickerModalProps = {
2730
onClose?: () => void;
2831
};
2932

30-
function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear(), onYearChange, onClose}: YearPickerModalProps) {
33+
function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear(), onYearChange, onClose, isRHPVisible}: YearPickerModalProps) {
3134
const styles = useThemeStyles();
3235
const {translate} = useLocalize();
3336
const [searchText, setSearchText] = useState('');
@@ -59,6 +62,7 @@ function YearPickerModal({isVisible, years, currentYear = new Date().getFullYear
5962
onBackdropPress={onClose}
6063
enableEdgeToEdgeBottomSafeAreaPadding
6164
shouldUseReanimatedModal
65+
backdropOpacity={isRHPVisible ? 0 : undefined}
6266
>
6367
<ScreenWrapper
6468
style={[styles.pb0]}

src/components/DatePicker/CalendarPicker/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
77
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
88
import Text from '@components/Text';
99
import useLocalize from '@hooks/useLocalize';
10+
import useOnyx from '@hooks/useOnyx';
1011
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1112
import useThemeStyles from '@hooks/useThemeStyles';
1213
import DateUtils from '@libs/DateUtils';
1314
import CONST from '@src/CONST';
15+
import ONYXKEYS from '@src/ONYXKEYS';
1416
import ArrowIcon from './ArrowIcon';
1517
import Day from './Day';
1618
import generateMonthMatrix from './generateMonthMatrix';
@@ -67,6 +69,9 @@ function CalendarPicker({
6769
const [isYearPickerVisible, setIsYearPickerVisible] = useState(false);
6870
const isFirstRender = useRef(true);
6971

72+
const [isRHPVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: (modal) => modal?.type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED, canBeMissing: true});
73+
const isRHPVisibleWhenOpened = useRef(isRHPVisible).current;
74+
7075
const currentMonthView = currentDateView.getMonth();
7176
const currentYearView = currentDateView.getFullYear();
7277
const calendarDaysMatrix = generateMonthMatrix(currentYearView, currentMonthView);
@@ -301,6 +306,7 @@ function CalendarPicker({
301306
years={years}
302307
currentYear={currentYearView}
303308
onYearChange={onYearSelected}
309+
isRHPVisible={isRHPVisibleWhenOpened}
304310
onClose={() => setIsYearPickerVisible(false)}
305311
/>
306312
</View>

0 commit comments

Comments
 (0)