Skip to content

Layout glitch on pane switch #1

Description

@siepmann

Problem

Switching between panes (Cleanup, Duplicates, Apps, History) in
ContentView caused a visible layout glitch: a stray gap would appear
below the content, along with a shadow that rendered incorrectly for a
frame or two before settling.

Root cause

The Window scene for the main window declared both:

Window(AppInfo.name, id: AppInfo.mainWindowID) {
    ContentView(scanner: scanner, updater: updater, duplicates: duplicates, uninstaller: uninstaller)
        .fixedSize()
}
.windowResizability(.contentSize)

.fixedSize() and .windowResizability(.contentSize) are two
independent mechanisms that both try to size the window to fit its
content. With both active at once, they produced competing size
calculations on the same frame.

This became visible specifically on pane switches because each pane
has a very different intrinsic height — Cleanup includes a scrollable
list with a fixed height: 440, while Duplicates, Apps, and
History are considerably shorter. Whenever pane changed, SwiftUI
had to recompute a very different content size, and the two competing
resize paths fell out of sync for a moment, leaving a rendering
artifact (gap + wrong shadow) before the window caught up.

The same ContentView is also used inside a MenuBarExtra with
.menuBarExtraStyle(.window), which is generally more sensitive to
abrupt height changes, making the glitch more noticeable there.

Fix

Removed the redundant .fixedSize() modifier from the Window scene
and let .windowResizability(.contentSize) be the single source of
truth for sizing the window to its content:

Window(AppInfo.name, id: AppInfo.mainWindowID) {
    ContentView(scanner: scanner, updater: updater, duplicates: duplicates, uninstaller: uninstaller)
}
.windowResizability(.contentSize)

With only one sizing mechanism in play, pane switches now resize
cleanly with no leftover gap or shadow artifact.

Testing

  • Switched between all four panes (Cleanup, Duplicates, Apps,
    History) repeatedly in both the menu bar popover and the standalone
    window — no gap or shadow glitch observed.
  • Confirmed the window still sizes correctly to content on first
    appearance and after scans/deletes that change the list height.
Screen.Recording.2026-08-19.at.09.27.54.mov

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions