AgendaList component does not scroll to the initially selected date (date prop in the CalendarProvider) at component mount. Also reselecting that date in the calendar doesn't scroll, because the AgendaList doesn't detect a date change. Also if the selected day is today, there is no scroll to "Today" button, although the component does not display that date.
On component mount the AgendaList should display the date selected by the date prop in the CalendarProvider component.
AgendaList displays the first component from the sections prop array.
Please run these commands in the project folder and fill in their results:
npm ls react-native-calendars: [email protected] npm ls react-native: [email protected] Also specify:
date={ITEMS[0].title} to date={ITEMS[3].title}have same problem
Hey, I'm facing the same issue. when I update the selected date (in my case it is Today) when my data updates than AgendaList doesn't scroll to that date. It always shows the first element in the data array.
Anyone who can help me in this issue,
Thanks. :)
Same problem here!
I am facing the same issue here.
Using react-native-calendars v1.282.0. Using Android.
The code bellow is executing:
componentDidMount() {
const { date } = this.props.context;
if (date !== this._topSection) {
setTimeout(() => {
const sectionIndex = this.getSectionIndex(date); // --> finding section 7 (correct)
this.scrollToSection(sectionIndex);
}, 500);
}
}
scrollToSection(sectionIndex) {
if (this.list.current && sectionIndex !== undefined) {
this.sectionScroll = true; // to avoid setDate() in onViewableItemsChanged
this._topSection = this.props.sections[sectionIndex].title;
this.list.current.scrollToLocation({
animated: true,
sectionIndex: sectionIndex,
itemIndex: 0,
viewPosition: 0, // position at the top
viewOffset: commons.isAndroid ? this.sectionHeight : 0 // -> sectionHeight is undefined, maybe here is the bug
});
}
}
Is it consistent? @JulioOrellana
Does increasing the time out are fixing the problem?
We need to think about a better solution.
Is it consistent? @JulioOrellana
Does increasing the time out are fixing the problem?
We need to think about a better solution.
Nope, it is not fixing it, but I am trying a few things
Please check that the date you are passing is correct and it his a section to scroll to.
Yes, dates are correct
agendaList dates:
2019-11-05 <- top date
2020-06-05 <- prop date
But I seems to be working if timeout is greater tan 2 seconds, because if I use 2000 in timeout, it scrolls to index.
FlatList his a prop called onContentSizeChanged.
Can you try to use it? (Without timeout)
Hi,
Does there is a fix for this one ?
I am facing the same issue.
Thx
Most helpful comment
have same problem