Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Able to multiple selections after reloadData() #1299

Open
dabaicaifen opened this issue Oct 26, 2020 · 7 comments
Open

Able to multiple selections after reloadData() #1299

dabaicaifen opened this issue Oct 26, 2020 · 7 comments
Assignees

Comments

@dabaicaifen
Copy link

(Required) Version Number: 8.0.3

Description

Demo: Demo Project
After reloadData() called, the calendar can be highlighted with multiple dates, even already disabled multiple selections.

Steps To Reproduce

1, Run the demo project
2, Selected someday outside the current month (such as Nov 3)
3, Click the table row to open a detail page.
4, Go back and click another day outside of the current month (such as Nov 4)
5, Observe, the 3rd and 4th are both highlighted.

Expected Behavior

Only the new selected day should be highlighted, in this case, the Nov 4th.

Additional Context

Testing on 7.1.8, there's no issue.

@patchthecode
Copy link
Owner

OK. I'll take a look after work today.

@patchthecode
Copy link
Owner

Just got time. Taking a look at this now.

@patchthecode
Copy link
Owner

patchthecode commented Nov 10, 2020

Are you still experiencing this? and if so, what version of XCode are you using?
Im currently on XCode12 and every thing looks fine.

The only clue that I have based on what you have said, is that

it works well on version 7.1.8

This lets me think that you have probably upgraded. If this is the case, then maybe your deselect/select function name needs to be updated?

I have the migration guide over here where I show all the names of the function that has been changed.
--> https://patchthecode.com/jtapplecalendar-version-8-0-0-migration-guide/

Apologies for the late reply, but time in 2020 is a bit hard to come by for me.
Let me know if this is the issue

@dabaicaifen
Copy link
Author

dabaicaifen commented Nov 11, 2020

Hi @patchthecode , I'm still seeing this error.
And if you see my demo (The commented code is for version 7): https://github.com/dabaicaifen/CalendarDemo/blob/main/CalendarDemo/Sources/Controllers/ViewController.swift.

I'm using the correct delegate methods.
I'm using Xcode 12.2 right now, but when I create this demo, I think I'm using Xcode 12 or 12.0.1.

The key step to reproduce this error is setting the current date as Oct 23.

@RakeshCodeNinja
Copy link

Hey @patchthecode I am also facing this issue.

@jvisenti
Copy link
Contributor

I'm also seeing this issue on v8.0.3. To test I implemented the select and deselect delegate callbacks:

func calendar(_ calendar: JTACMonthView, didSelectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath)
func calendar(_ calendar: JTACMonthView, didDeselectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath)

In some cases didSelectDate was invoked without a corresponding didDeselectDate, which resulted in calendar.selectedDates.count == 2. Continuing to select different dates would eventually resolve the issue and the calendar would return to just having 1 date selected. As a workaround, I was able to manually deselect the extra dates:

func calendar(_ calendar: JTACMonthView, didSelectDate date: Date, cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath) {
    calendar.deselect(dates: calendar.selectedDates.filter { $0 != date })
    ...
}

But this does appear to be a library issue.

@dabaicaifen
Copy link
Author

Hi @jvisenti , I just tried your solution on the demo project that I had attached with this issue https://github.com/dabaicaifen/CalendarDemo.
The workaround is not working in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants