diff --git a/Sources/AquaKit/Drawers/AquaDrawer.swift b/Sources/AquaKit/Drawers/AquaDrawer.swift index 50e7e99..3b165c8 100644 --- a/Sources/AquaKit/Drawers/AquaDrawer.swift +++ b/Sources/AquaKit/Drawers/AquaDrawer.swift @@ -271,6 +271,12 @@ public class AquaDrawer: NSWindowController { } } + private func finalizeClose() { + self.window?.orderOut(nil) + self.state = .closedState + NotificationCenter.default.post(name: Self.didCloseNotification, object: self) + } + public override func close() { guard case .openState(let edge) = state, @@ -283,15 +289,16 @@ public class AquaDrawer: NSWindowController { NotificationCenter.default.post(name: Self.willCloseNotification, object: self) state = .closingState + // Edge case: when the window has zero size, its origin may turn to zero for reasons unknown. To avoid the resulting animation glitch, we just don't animate at all in this case. + guard window.frame != .zero else { return finalizeClose() } + NSAnimationContext.runAnimationGroup { context in context.duration = Self.drawerTransitionDuration window.animator().setFrame(frame, display: true) } completionHandler: { [weak self] in if let self { Task { @MainActor in - self.window?.orderOut(nil) - self.state = .closedState - NotificationCenter.default.post(name: Self.didCloseNotification, object: self) + self.finalizeClose() } } }