Skip to content

Commit caa0ab6

Browse files
authored
CalendarList - fix staticHeader moves month out of range (#2242)
* CalendarList - fix staticHeader moves month out of range * revert screen change
1 parent 79b605a commit caa0ab6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/calendar-list/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
137137
});
138138
}, [items]);
139139

140+
const getDateIndex = useCallback((date: string) => {
141+
return findIndex(items, function(item) {
142+
return item.toString() === date.toString();
143+
});
144+
}, [items]);
145+
140146
useEffect(() => {
141147
if (current) {
142148
scrollToMonth(new XDate(current));
@@ -188,7 +194,7 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
188194

189195
const addMonth = useCallback((count: number) => {
190196
const day = currentMonth?.clone().addMonths(count, true);
191-
if (sameMonth(day, currentMonth)) {
197+
if (sameMonth(day, currentMonth) || getDateIndex(day) === -1) {
192198
return;
193199
}
194200
scrollToMonth(day);
@@ -280,7 +286,7 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
280286
onViewableItemsChanged
281287
},
282288
]);
283-
289+
284290
return (
285291
<View style={style.current.flatListContainer} testID={testID}>
286292
<FlatList

0 commit comments

Comments
 (0)