Skip to content

fix: side-by-side diff scroll desync on hidden-tab rebuild and tab switch - #2611

Merged
love-linger merged 1 commit into
sourcegit-scm:developfrom
JC-Chung:fix/side-by-side-scroll-sync-hidden-tab
Aug 7, 2026
Merged

fix: side-by-side diff scroll desync on hidden-tab rebuild and tab switch#2611
love-linger merged 1 commit into
sourcegit-scm:developfrom
JC-Chung:fix/side-by-side-scroll-sync-hidden-tab

Conversation

@JC-Chung

@JC-Chung JC-Chung commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Why

OnLoaded + FindDescendantOfType<ScrollViewer>() assumed the control
template was already applied, which broke in two cases:

  1. Presenter rebuilt while its container is hidden (IsVisible=false),
    e.g. toggling the shared Preferences.UseSideBySideDiff from the
    other LOCAL/HISTORY tab — Loaded fires but template application
    (tied to layout) is skipped for hidden subtrees.
  2. Commit-detail tabs (Info/Changes/Files) reuse the same presenter
    instance across tab switches — clearing _scrollViewer to null in
    OnUnloaded permanently lost the binding since OnApplyTemplate
    only runs once per instance.

Fix

Move ScrollViewer lookup + offset binding into OnApplyTemplate
(matching MergeConflictTextPresenter), force ApplyTemplate() in
OnLoaded, and stop resetting _scrollViewer in OnUnloaded.

Test

  1. Toggle Side-by-Side in LOCAL/HISTORY tab, switch to the other — stays synced.
  2. Commit detail: Changes → Info/Files → back to Changes — stays synced.
@love-linger

love-linger commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

It's not necessary add move code to OnApplyTemplate after manually calling ApplyTemplate() in OnLoaded.

All we need is adding a single line ApplyTemplate(); after calling base.OnLoaded(e)

@love-linger love-linger self-assigned this Aug 7, 2026
@JC-Chung
JC-Chung force-pushed the fix/side-by-side-scroll-sync-hidden-tab branch from 1fe9919 to 91bd4cb Compare August 7, 2026 02:25
@love-linger

Copy link
Copy Markdown
Collaborator

Tested it manually. Looks good to me.

@love-linger
love-linger merged commit 16b965f into sourcegit-scm:develop Aug 7, 2026
8 checks passed
@JC-Chung
JC-Chung deleted the fix/side-by-side-scroll-sync-hidden-tab branch August 7, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants