Skip to content

Commit ada1c2d

Browse files
committed
Fixed regression introduced in 1.1.0 where a window-based MenuBarExtra would fail to close its window (#14)
1 parent 03f6bfb commit ada1c2d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/MenuBarExtraAccess/MenuBarExtraAccess.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ struct MenuBarExtraAccess<Content: Scene>: Scene {
150150
print("MenuBarExtra index \(index) drop-down window did resign as key.")
151151
#endif
152152

153+
// it's possible for a window to resign key without actually closing, so let's
154+
// close it as a failsafe.
155+
if window.isVisible {
156+
#if DEBUG
157+
print("Closing MenuBarExtra index \(index) drop-down window as a result of it resigning as key.")
158+
#endif
159+
160+
window.close()
161+
}
162+
153163
MenuBarExtraUtils.setKnownPresented(for: .index(index), state: false)
154164
isMenuPresented = false
155165
}

0 commit comments

Comments
 (0)