Skip to content

Commit ef1b41f

Browse files
lividclaude
andcommitted
Skip launch-restore scroll on macOS 12 to avoid corrupted List offset
On macOS 12, scrolling a SwiftUI List that is still settling its initial layout corrupts the scroll offset, leaving both the sidebar and article list pushed down with empty space above after launch. Gate the launch-time restore scrolls behind macOS 13 while keeping selection restore and article loading intact; user-initiated scrolls are unaffected on all versions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 6e5a2a9 commit ef1b41f

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

Planet/Entities/PlanetStore.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,23 @@ final class MyJSONDirectoryMonitor {
815815
selectedArticle = matchingArticle
816816
// Scroll the article list to reveal the restored selection.
817817
// Use a delay so SwiftUI has time to populate the List.
818+
// On macOS 12, scrolling a List that is still settling its initial
819+
// layout corrupts the scroll offset, so skip the launch-time
820+
// restore scroll there and only restore the selection.
818821
let article = matchingArticle
819822
let needsLoadNotification = isPendingRestore
823+
let needsScroll: Bool
824+
if #available(macOS 13.0, *) {
825+
needsScroll = true
826+
} else {
827+
needsScroll = !isPendingRestore
828+
}
820829
Task { @MainActor in
821830
try? await Task.sleep(nanoseconds: 300_000_000)
822831
guard self.selectedArticle?.id == article.id else { return }
823-
NotificationCenter.default.post(name: .scrollToArticle, object: article)
832+
if needsScroll {
833+
NotificationCenter.default.post(name: .scrollToArticle, object: article)
834+
}
824835
if needsLoadNotification {
825836
NotificationCenter.default.post(name: .loadArticle, object: nil)
826837
}
@@ -841,7 +852,11 @@ final class MyJSONDirectoryMonitor {
841852

842853
if pendingSidebarScroll {
843854
pendingSidebarScroll = false
844-
scrollSidebarToSelectedView()
855+
// pendingSidebarScroll is only set on the launch-restore path;
856+
// skip the scroll on macOS 12 for the same layout reason as above.
857+
if #available(macOS 13.0, *) {
858+
scrollSidebarToSelectedView()
859+
}
845860
}
846861
}
847862

Planet/versioning.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 2832
1+
CURRENT_PROJECT_VERSION = 2833

0 commit comments

Comments
 (0)