Skip to content

Commit d9b71d1

Browse files
committed
fix(inspector): add resize call site, refresh base size, fix animation race, add test
1 parent 0cc0c3a commit d9b71d1

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

TablePro/Core/Services/Infrastructure/MainSplitViewController.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
4040
private var detailHosting: NSHostingController<AnyView>!
4141
private var inspectorHosting: NSHostingController<AnyView>!
4242
private var hasMaterializedInspector = false
43-
private var baseWindowContentMinSize: NSSize?
4443

4544
// MARK: - Toolbar
4645

@@ -195,10 +194,7 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
195194
) {
196195
guard let window = view.window else { return }
197196

198-
if baseWindowContentMinSize == nil {
199-
baseWindowContentMinSize = window.contentRect(forFrameRect: NSRect(origin: .zero, size: window.minSize)).size
200-
}
201-
guard let baseWindowContentMinSize else { return }
197+
let baseWindowContentMinSize = window.contentRect(forFrameRect: NSRect(origin: .zero, size: window.minSize)).size
202198

203199
let resolvedMinSize = Self.resolvedContentMinSize(
204200
base: baseWindowContentMinSize,
@@ -289,6 +285,10 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
289285
removeObservers()
290286
}
291287

288+
override func splitViewDidResizeSubviews(_ notification: Notification) {
289+
recomputeWindowMinimumSize()
290+
}
291+
292292
// MARK: - Observers
293293

294294
private func installObservers() {
@@ -542,7 +542,9 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
542542
}
543543

544544
func hideInspector() {
545-
setCollapsed(true, for: inspectorSplitItem)
545+
setCollapsed(true, for: inspectorSplitItem) { [weak self] in
546+
self?.recomputeWindowMinimumSize(inspectorCollapsed: true)
547+
}
546548
UserDefaults.standard.set(false, forKey: Self.inspectorPresentedKey)
547549
}
548550

TableProTests/Core/Services/Infrastructure/MainSplitViewControllerWindowMinimumSizeTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,20 @@ struct MainSplitViewControllerWindowMinimumSizeTests {
5353
#expect(size.width == 720)
5454
#expect(size.height == 448)
5555
}
56+
57+
@Test("Uses the pane sum when detail and inspector exceed the base floor")
58+
func usesPaneSumWhenItExceedsBaseWithSidebarCollapsed() {
59+
let size = MainSplitViewController.resolvedContentMinSize(
60+
base: NSSize(width: 720, height: 448),
61+
panes: [
62+
.init(minimumThickness: 280, isCollapsed: true),
63+
.init(minimumThickness: 400, isCollapsed: false),
64+
.init(minimumThickness: 400, isCollapsed: false)
65+
],
66+
dividerThickness: 2
67+
)
68+
69+
#expect(size.width == 802)
70+
#expect(size.height == 448)
71+
}
5672
}

0 commit comments

Comments
 (0)