sfsam / Itsycal

Itsycal is a tiny calendar for your Mac's menu bar. http://www.mowglii.com/itsycal
MIT License
3.25k stars 234 forks source link

'Open Calendar' opens Calendar.app to the wrong event #244

Open SquaredTiki opened 4 weeks ago

SquaredTiki commented 4 weeks ago

Something strange seems to be happening for me when I use 'Open Calendar' in Itsycal to try to edit an event in Calendar.app.

If Calendar.app is closed at the time I click 'Open Calendar' on an event then it seems Calendar.app opens but highlights the event I last 'opened in Calendar' with.

If Calendar.app is open at the time I click 'Open Calendar' on an event then Calendar.app highlights an event that's off by one or two from the one I actually wanted. If I click 'Open Calendar' on an event that is on the same day Calendar.app already has visible then the selected event does not change.

I can't tell if this is a Calendar.app bug or an Itsycal bug.

sfsam commented 2 weeks ago

I'll have to investigate. I think I'm seeing something similar and I don't think it used to do this. I don't think I've changed anything, but can't be sure. Can you tell me what version of macOS you are on?

SquaredTiki commented 2 weeks ago

I'm on macOS 14.5

sfsam commented 1 week ago

Yes, 14.5 here as well. I'm going to tentatively call this an Apple bug.

I just tried controlling Calendar using Apple's Script Editor app. I gave it the following AppleScript:

tell application "Calendar"
    view calendar at current date
end tell

It opened Calendar to the last selected date (as you describe above) instead of the current date. But doing this a number of times I am unable to reliably get the bad behavior. Sometimes it works (!), sometimes it doesn't.

I also tried using AppleScript inside of Itsycal instead of my current ScriptingBridge implementation. As with Script Editor, sometimes it works and sometimes it doesn't. I'm stumped at the moment.

sfsam commented 1 week ago

I think Calendar.app might have some logic in it that remembers the previous date it was set to. If Calendar.app is closed and I open it to a new date with Itsycal, if I watch very closely I will see Calendar.app open to the correct date and then quickly revert to the previously selected one. It happens quickly so it seems like it is just opening at the wrong date.

Can you see if you notice this too?

When I change Itsycal's logic to open Calendar.app, wait 0.5 seconds, and then navigate to the date, it seems to work.

sfsam commented 1 week ago

I've made a test version with the delay if you'd like to try: https://itsycal.s3.amazonaws.com/Itsycal-0.15.3-open-calendar.zip

SquaredTiki commented 6 days ago

So interesting. That does seem to fix it not opening to the correct date, but it doesn't seem to fix it not opening to the correct event. Screen recording here: https://dropover.cloud/aa8e8f.

sfsam commented 6 days ago

Correct. The granularity is to the day, not the event unfortunately. I don't know how to open a specific event.