Comments (11)
Yeah, sounds good. do you want to create a PR for that?
from react-native-calendario.
@maggialejandro - Let me know if I did everything correct, this is my first time doing anything for open source! I appreciate you responding and helping me out these past couple days 🙌
from react-native-calendario.
*edit
Some further testing - looks like if the startDate
is 1 month or ahead of the current date today, the render issue happens above.
So when i select just the date Nov 5th, the render issue does not happen, but if select the startDate
to be Nov 6h, the render issue does happen
from react-native-calendario.
Hi @mvolonnino
could you please share a reproducible example? that would really help debugging the issue
from react-native-calendario.
Yes! so here is actually how im utilizing it and think i found one of the issues:
so my Calendar component looks like this:
return (
<View>
<CalendarIcon onPress={() => calendarRef.current?.present()} />
<BottomSheetModal
ref={calendarRef}
footerComponent={renderFooter}
snapPoints={['65%', '90%']}
title="Select Dates"
>
<BottomSheetFlatList // * BottomSheetFlatList needed for Android scroll support
data={[{ id: 'calendar' }]}
contentContainerStyle={{ paddingBottom: 130 }}
style={{ backgroundColor: colors.background }}
renderItem={() => (
<Calendar
key={dark.toString()} // force rerender on theme change
startingMonth={new Date().toISOString()}
viewableRangeOffset={5}
startDate={selectedDates.startDate}
endDate={selectedDates.endDate}
minDate={new Date()}
monthHeight={MONTH_HEIGHT}
numberOfMonths={13}
onPress={selectDates}
theme={getCalendarTheme(colors)}
disableOffsetDays
/>
)}
keyExtractor={item => item.id}
/>
</BottomSheetModal>
</View>
);
So to be able to actually scroll within a BottomSheetModal from gorham on Android, you need to either have it inside a FlatList from react-native-gesture-handler
or its BottomSheetFlatList
component. This gives gesture support to the bottom sheet, while also being able to scroll within the flatlist.
Looks like when i remove it from the BottomSheetFlatList,
the calendar opens up to the month that has the startDate
selected, and scrolling up shows the current month (in this case Oct).
This breaks the gesture support within the BottomSheetModal
though, and I cannot scroll at all on Android device through the Calendar, instead, the gesture is captured only by the BottomSheetModal.
So looks like by implementing the workaround for Android to get scrolling of the months possible in the bottom sheet, this render issue happens
@maggialejandro - sorry, i've also never done a 'reproducible example' before, is there something else you need me to do?
from react-native-calendario.
I couldn't reproduce the bug
check this branch
Simulator.Screen.Recording.-.iPhone.14.-.2023-10-08.at.20.14.13.mp4
from react-native-calendario.
mhm, in your code it doesn't look like the Calendar
component wrapped within a BottomSheetFlatList
as well. Im curious, are you able to scroll through the calendar on an Android device? The issue I have is that the scrolling does not pass through to the Calendar
component while its wrapped in that BottomSheetModal
.
Need that type of setup for the Gorham Bottom Sheet to be able to scroll within the Calendar component on Android. iOS worked without doing needing that workaround
Im wondering if there could be a prop passed to the Calendar
component that would always have it open to the startingMonth
prop or something like that
from react-native-calendario.
I see, it seems to be a @gorhom/bottom-sheet
issue on Android.
It makes sense that if you add a scrollable component the calendar won't scroll to the correct month.
You could fork this library and replace Calendar's FlatList with gorhom's BottomSheetFlatList
instead
from react-native-calendario.
I just tried and tested with the BottomSheetFlatList
component, the performance takes a bit of a hit when just plugging that in.
I think a pretty simple and easy fix/workaround could be just exposing the initialScrollIndex
that can override if one is passed in
initialScrollIndex={
props.initialScrollIndex ?? !isWeb && !calculateMonthHeightDynamically ? firstMonthIndex : 0
}
when commenting out that line in Calendar.tsx
line 286, the render issue is gone, and performance stays the same when testing on iOS and Android device.
This way, the Calendar
can still be used within a BottomSheetFlatList
in how I have it implemented above, with passing initialScrollIndex={0}
and startingMonth
in conjunction to have it open to the starting month everytime and not worry about scrolling to the selected date.
Do you think that is a valid fix for this specific issue im running into?
from react-native-calendario.
awesome, thank you!
from react-native-calendario.
Related Issues (20)
- The component does not re-render HOT 12
- Calendar doesn't appear until press HOT 8
- disabledDays not working HOT 3
- Single Month - Scroll Horizontal HOT 1
- Unable to set starting month? HOT 1
- endDateContainerStyle doesn't work
- Annual view HOT 1
- Feature request: Add inverted prop to start Calendar at the bottom HOT 2
- UI Freezes when selecting a range of days with `renderDayContent` function. HOT 2
- Visible delay in initial rendering of the Calendar in mobile device HOT 3
- Calendar slides out of view when used in Modal HOT 5
- feature request: prop for `contentContainerStyle` HOT 1
- calculateMonthHeightDynamically disable automatic scroll to startDate HOT 2
- disableOffsetDays theming issue + range issue HOT 4
- Range select is not working (maybe cached onPress) HOT 11
- Custom renderer prop (could be useful for bottom-sheet or flashlist) HOT 4
- Date range selection HOT 4
- The calendar is not clickable in months that are not displayed in the first rendering HOT 3
- Bug with style activeDayContainerStyle HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-calendario.