Skip to content

Fix: auto-scroll tab bar to active tab#60

Merged
Gabko14 merged 1 commit intomainfrom
fix/tab-bar-auto-scroll
Feb 25, 2026
Merged

Fix: auto-scroll tab bar to active tab#60
Gabko14 merged 1 commit intomainfrom
fix/tab-bar-auto-scroll

Conversation

@Gabko14
Copy link
Owner

@Gabko14 Gabko14 commented Feb 25, 2026

Summary

  • Wraps the tab bar ScrollView in a ScrollViewReader to enable programmatic scrolling
  • Scrolls to the active tab on appear (fixes opening Ghostly with a far-right active tab)
  • Scrolls to the active tab on change (fixes new tab creation and keyboard navigation with many tabs)

Test plan

  • Create 15+ tabs, verify new tab is scrolled into view
  • With many tabs, use Cmd+Shift+] / [ to navigate — verify tab scrolls into view
  • Quit and reopen with a far-right tab active — verify it's visible on launch
  • All existing tests pass

Wrap the tab bar ScrollView in a ScrollViewReader and scroll to the
active tab on appear and whenever activeTabId changes. Fixes tabs
being off-screen when opening the app with a far-right active tab,
creating new tabs, or navigating via keyboard shortcuts.
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approved

Summary: Clean implementation of auto-scroll behavior for the tab bar using standard SwiftUI patterns.

What's Good

  1. Correct pattern usage: ScrollViewReader + .id() is the idiomatic SwiftUI approach for programmatic scrolling

  2. Proper nil handling: Guard clauses correctly handle the optional activeTabId

  3. Good UX decisions:

    • onAppear scroll has no animation (avoids jarring startup effect)
    • onChange scroll uses smooth .easeInOut(duration: 0.2) animation
    • .center anchor keeps active tab visible with context
  4. Minimal change: Restructures only what's necessary, no over-engineering

Testing

Per project conventions (CLAUDE.md), UI scroll behavior can't be unit tested due to MenuBarExtra limitations. The manual test plan is thorough and appropriate for this change.

Minor Note

No issues, but for awareness: if activeTabId changes rapidly (e.g., holding down Cmd+Shift+]), animations will queue. This is standard SwiftUI behavior and should be fine in practice since the final position will be correct.

LGTM

@Gabko14 Gabko14 merged commit 24dfad6 into main Feb 25, 2026
3 checks passed
@Gabko14 Gabko14 deleted the fix/tab-bar-auto-scroll branch February 25, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant