pakerwreah / Calendr

Menu bar calendar for macOS
MIT License
1.08k stars 45 forks source link

Calendar app isn't bring to front when opened from calendar icon #260

Open laurentNoudohounsi opened 1 day ago

laurentNoudohounsi commented 1 day ago

I noticed that when I click on the calendar button to open the calendar with other applications running (like Safari), the Calendar isn't bring to front and is hidden by other app.

It could be unsettling because user could think the button is not working.

After looking at the code, the issue comes from the Calendar Apple Script: https://github.com/pakerwreah/Calendr/blob/15bc7bd50aa91cc732289d147a0d481c32fe961c/Calendr/Automation/CalendarScript.swift#L27C1-L32C21

The fix is to add the line activate like this

tell application "Calendar"
    activate
    switch view to \(mode) view
    view calendar at date ("\(formatter.string(from: date))")
end tell

This way, the Calendar app will be opened and brought to front.