Skip to content

Commit b4ce482

Browse files
committed
fix: prevent duplicate window on reopen from dock
Use Window scene instead of WindowGroup to prevent SwiftUI from creating a second window when the app is reopened via dock icon while the original window is hidden (not closed). WindowGroup is designed for multi-window apps and creates a new window instance when no visible window exists. Window is a single- instance scene type that correctly handles the hidden window case.
1 parent ce7a89f commit b4ce482

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

App/KasetApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct KasetApp: App {
112112
}
113113

114114
var body: some Scene {
115-
WindowGroup {
115+
Window("Kaset", id: "main") {
116116
// Skip UI during unit tests to prevent window spam
117117
if UITestConfig.isRunningUnitTests, !UITestConfig.isUITestMode {
118118
Color.clear

Views/macOS/MainWindow.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ struct MainWindow: View {
260260

261261
/// Returns the view for a specific navigation item.
262262
@ViewBuilder
263-
// swiftlint:disable:next cyclomatic_complexity
264-
private func viewForNavigationItem(_ item: NavigationItem) -> some View {
263+
private func viewForNavigationItem(_ item: NavigationItem) -> some View { // swiftlint:disable:this cyclomatic_complexity
265264
Group {
266265
switch item {
267266
case .home:

0 commit comments

Comments
 (0)