diff --git a/src/expandableCalendar/index.tsx b/src/expandableCalendar/index.tsx index bd76df3ed0..9b557dfa26 100644 --- a/src/expandableCalendar/index.tsx +++ b/src/expandableCalendar/index.tsx @@ -452,6 +452,22 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => { }, [onPressArrowRight, scrollPage]); const _onDayPress = useCallback((value: DateData) => { + const threshold = isOpen ? openHeight.current - closeThreshold : closedHeight + openThreshold; + const _isOpen = _height.current >= threshold; + if (_isOpen) return; + if (numberOfDaysCondition) { + setDate?.(value.dateString, UpdateSources.DAY_PRESS); + } + if (closeOnDayPress) { + closeCalendar(); + } + onDayPress?.(value); + }, [onDayPress, closeOnDayPress, closeCalendar, numberOfDaysCondition]); + + const _onCalendarListDayPress = useCallback((value) => { + const threshold = isOpen ? openHeight.current - closeThreshold : closedHeight + openThreshold; + const _isOpen = _height.current >= threshold; + if (!_isOpen) return; if (numberOfDaysCondition) { setDate?.(value.dateString, UpdateSources.DAY_PRESS); } @@ -587,7 +603,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => { current={date} theme={themeObject} ref={calendarList} - onDayPress={_onDayPress} + onDayPress={_onCalendarListDayPress} onVisibleMonthsChange={onVisibleMonthsChange} pagingEnabled scrollEnabled={isOpen}