Skip to content

Commit 0ef3d32

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

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

@@ -212,10 +211,7 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
212211
) {
213212
guard let window = view.window else { return }
214213

215-
if baseWindowContentMinSize == nil {
216-
baseWindowContentMinSize = window.contentRect(forFrameRect: NSRect(origin: .zero, size: window.minSize)).size
217-
}
218-
guard let baseWindowContentMinSize else { return }
214+
let baseWindowContentMinSize = window.contentRect(forFrameRect: NSRect(origin: .zero, size: window.minSize)).size
219215

220216
let resolvedMinSize = Self.resolvedContentMinSize(
221217
base: baseWindowContentMinSize,
@@ -306,6 +302,10 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
306302
removeObservers()
307303
}
308304

305+
override func splitViewDidResizeSubviews(_ notification: Notification) {
306+
recomputeWindowMinimumSize()
307+
}
308+
309309
// MARK: - Observers
310310

311311
private func installObservers() {
@@ -559,7 +559,9 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
559559
}
560560

561561
func hideInspector() {
562-
setCollapsed(true, for: inspectorSplitItem)
562+
setCollapsed(true, for: inspectorSplitItem) { [weak self] in
563+
self?.recomputeWindowMinimumSize(inspectorCollapsed: true)
564+
}
563565
UserDefaults.standard.set(false, forKey: Self.inspectorPresentedKey)
564566
}
565567

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)