You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when clicked event 2, we can see event 3 behind event 2.
currently I fixed this by replacing the event sorting algorithm.
However, this code changes some of the sort order, and can't use option 'sortedMonthView=false'.
If someone needs to fix the bug now, use the code below temporarily.
CalendarBodyForMonthView.tsx, line 119
consteventsByDate=React.useMemo(()=>{letmultipleDayEventsOrder:Map<T,number>=newMap();leteventDict: {[date: string]: T[]}={};letdateToCompare=dayjs(targetDate).startOf('month').startOf('week').startOf('day');letstartDateOfWeek=dateToCompare.startOf('week');letlastDateOfWeek=dateToCompare.endOf('week');letlastDateOfMonth=dayjs(targetDate).endOf('month').endOf('week').endOf('day').add(1,'day');while(dateToCompare.isBefore(lastDateOfMonth,'day')){//Update the relevant variables to the next week when the date you're currently trying to index is past the last date of the current week//Initialize the order index for multi-date events, as the order of multi-date events changes every week.if(dateToCompare.isAfter(lastDateOfWeek)){multipleDayEventsOrder.clear();startDateOfWeek=dayjs(dateToCompare).startOf('week');lastDateOfWeek=dayjs(dateToCompare).endOf('week');}//Get all the vevents that start today and sort them.lettodayStartsEvents=events.filter((event)=>dateToCompare.isSame(dayjs(event.start).startOf('day'),'day')||(dateToCompare.isSame(startDateOfWeek,'day')&&dateToCompare.isBetween(dayjs(event.start).startOf('day'),dayjs(event.end).startOf('day'),'day','[]'))).sort((a,b)=>{if(dayjs(a.start).startOf('day').isBefore(dayjs(a.end).startOf('day'),'day')||dayjs(a.start).startOf('day').isBefore(dayjs(b.end).startOf('day'),'day')){constaDuration=dayjs.duration(dayjs(a.end).diff(dayjs(a.start))).days()constbDuration=dayjs.duration(dayjs(b.end).diff(dayjs(b.start))).days()returnbDuration-aDuration}returnb.start.getTime()-a.start.getTime()});lettodayStartsEventsSet=newSet(todayStartsEvents);letfinalEvents=[...todayStartsEvents];// Import and sort events that don't start today, but are included today.lettodayIncludedEvents=events.filter((event)=>dateToCompare.isBetween(dayjs(event.start).startOf('day'),dayjs(event.end).startOf('day'),'day','[]')&&!todayStartsEventsSet.has(event)).sort((a,b)=>(multipleDayEventsOrder.get(a)??0)-(multipleDayEventsOrder.get(b)??0));// Inserts an existing multi-day event into today's schedule,// preserving the order of the existing multi-day event.todayIncludedEvents.forEach((event)=>{if(!multipleDayEventsOrder.has(event))return;letorder=multipleDayEventsOrder.get(event);if(order===undefined)return;finalEvents.splice(order,0,event);});eventDict[dateToCompare.format(SIMPLE_DATE_FORMAT)]=finalEvents;//Pre-indexes locations in a multi-date event starting with the current date//for use in the next date index.finalEvents.forEach((event)=>{if(dayjs(event.end).diff(dayjs(event.start),'day')>0){multipleDayEventsOrder.set(event,finalEvents.indexOf(event));}});dateToCompare=dateToCompare.add(1,'day');}returneventDict;},[events,sortedMonthView]);
Hmm this must be a complicated issue... If you send a pull request, I'm happy merge it though.
Please don't forget to update the storybook format if you do so. Thanks!
reproducible storybook code
result
when clicked event 2, we can see event 3 behind event 2.
currently I fixed this by replacing the event sorting algorithm.
However, this code changes some of the sort order, and can't use option 'sortedMonthView=false'.
If someone needs to fix the bug now, use the code below temporarily.
CalendarBodyForMonthView.tsx, line 119
add this, and remove
sortedEvents
.CalendarBodyForMonthView.tsx, line 333
before
after
The text was updated successfully, but these errors were encountered: