From 9ec6ed2497db3f5f313e0de4ba2c405710bfe6ec Mon Sep 17 00:00:00 2001 From: Jon Sterling Date: Mon, 16 Feb 2026 23:03:09 +0000 Subject: [PATCH] Drawer resizing: work around an edge case --- Sources/AquaKit/Drawers/AquaDrawer.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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() } } } -- 2.51.2