-
-
Notifications
You must be signed in to change notification settings - Fork 329
fix(coordinator): stop a Users & Roles tab from pinning the window split dividers (#1872) #1875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
TablePro/Extensions/NSLayoutConstraintPriority+SplitPane.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import AppKit | ||
|
|
||
| internal extension NSLayoutConstraint.Priority { | ||
| static let splitPaneHolding = NSLayoutConstraint.Priority(260) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import CoreGraphics | ||
|
|
||
| internal enum UsersRolesLayoutMetrics { | ||
| static let principalListMinimumWidth: CGFloat = 200 | ||
| static let principalListMaximumWidth: CGFloat = 520 | ||
| static let principalDetailMinimumWidth: CGFloat = 560 | ||
|
|
||
| static let privilegeScopeMinimumWidth: CGFloat = 200 | ||
| static let privilegeScopeMaximumWidth: CGFloat = 640 | ||
| static let privilegeChecklistMinimumWidth: CGFloat = 300 | ||
|
|
||
| static var tabMinimumWidth: CGFloat { principalDetailMinimumWidth } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
TableProTests/Services/MainSplitViewControllerDetailWidthTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import AppKit | ||
| import Foundation | ||
| @testable import TablePro | ||
| import Testing | ||
|
|
||
| @Suite("Split pane holding priority") | ||
| @MainActor | ||
| struct SplitPaneHoldingPriorityTests { | ||
| private static let dragThatCannotResizeWindow: Float = 490 | ||
|
|
||
| @Test("A held pane still yields to a divider drag") | ||
| func heldPaneYieldsToDivider() { | ||
| #expect(NSLayoutConstraint.Priority.splitPaneHolding.rawValue < Self.dragThatCannotResizeWindow) | ||
| } | ||
|
|
||
| @Test("A held pane still outranks its sibling when the container resizes") | ||
| func heldPaneOutranksSibling() { | ||
| #expect( | ||
| NSLayoutConstraint.Priority.splitPaneHolding.rawValue | ||
| > NSLayoutConstraint.Priority.defaultLow.rawValue | ||
| ) | ||
| } | ||
|
|
||
| @Test("Privilege editor keeps room to drag at the tab's minimum width") | ||
| func privilegeEditorKeepsDragRoom() { | ||
| let required = UsersRolesLayoutMetrics.privilegeScopeMinimumWidth | ||
| + UsersRolesLayoutMetrics.privilegeChecklistMinimumWidth | ||
| #expect(UsersRolesLayoutMetrics.tabMinimumWidth - required >= 50) | ||
| } | ||
| } | ||
|
|
||
| @Suite("MainSplitViewController detail width") | ||
| @MainActor | ||
| struct MainSplitViewControllerDetailWidthTests { | ||
| @Test("Nil tab type falls back to the default detail minimum") | ||
| func nilTabTypeUsesDefault() { | ||
| let resolved = MainSplitViewController.resolveDetailMinimumThickness(for: nil) | ||
| #expect(resolved == MainSplitViewController.defaultDetailMinThickness) | ||
| } | ||
|
|
||
| @Test("Users & Roles declares the width its panes actually need") | ||
| func usersRolesDeclaresItsOwnMinimum() { | ||
| let resolved = MainSplitViewController.resolveDetailMinimumThickness(for: .usersRoles) | ||
| #expect(resolved == UsersRolesLayoutMetrics.tabMinimumWidth) | ||
| #expect(resolved == 560) | ||
| } | ||
|
|
||
| @Test( | ||
| "Every other tab type keeps the default detail minimum", | ||
| arguments: [TabType.query, .table, .createTable, .erDiagram, .serverDashboard] | ||
| ) | ||
| func otherTabTypesUseDefault(tabType: TabType) { | ||
| let resolved = MainSplitViewController.resolveDetailMinimumThickness(for: tabType) | ||
| #expect(resolved == MainSplitViewController.defaultDetailMinThickness) | ||
| #expect(resolved == 400) | ||
| } | ||
|
|
||
| @Test("Users & Roles fits its privilege editor once the principal list collapses") | ||
| func usersRolesMinimumFitsCollapsedLayout() { | ||
| let privilegeEditorWidth = UsersRolesLayoutMetrics.privilegeScopeMinimumWidth | ||
| + UsersRolesLayoutMetrics.privilegeChecklistMinimumWidth | ||
| #expect(UsersRolesLayoutMetrics.tabMinimumWidth >= privilegeEditorWidth) | ||
| } | ||
|
|
||
| @Test("Both panels hidden collapses to the base window minimum") | ||
| func collapsedPanelsUseBaseWindowMinimum() { | ||
| let width = MainSplitViewController.resolveWindowMinWidth( | ||
| detailMinimum: MainSplitViewController.defaultDetailMinThickness, | ||
| sidebarVisible: false, | ||
| inspectorVisible: false, | ||
| dividerThickness: 1 | ||
| ) | ||
| #expect(width == MainSplitViewController.baseWindowMinWidth) | ||
| } | ||
|
|
||
| @Test("Both panels visible sums sidebar, detail, inspector and dividers") | ||
| func visiblePanelsSumThicknesses() { | ||
| let width = MainSplitViewController.resolveWindowMinWidth( | ||
| detailMinimum: MainSplitViewController.defaultDetailMinThickness, | ||
| sidebarVisible: true, | ||
| inspectorVisible: true, | ||
| dividerThickness: 1 | ||
| ) | ||
| #expect(width == 952) | ||
| } | ||
|
|
||
| @Test("A Users & Roles tab widens the window minimum instead of pinning the inspector") | ||
| func usersRolesWidensWindowMinimum() { | ||
| let width = MainSplitViewController.resolveWindowMinWidth( | ||
| detailMinimum: MainSplitViewController.resolveDetailMinimumThickness(for: .usersRoles), | ||
| sidebarVisible: true, | ||
| inspectorVisible: true, | ||
| dividerThickness: 1 | ||
| ) | ||
| #expect(width == 1_112) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a Users & Roles tab is narrowed, setting
primaryItem.isCollapsed = trueon this autosaving split view can persist the zero-width primary pane underautosaveName. If the tab/window is later recreated at a wide size,didAutoCollapsePrimarystarts asfalse, so the restore path looks like a manual collapse and line 120 never expands the principal list. Users who once narrow the tab can therefore reopen it with the user list stuck hidden; avoid autosaving the automatic collapse or record enough state to undo it after restore.Useful? React with 👍 / 👎.