Skip to content

Fix scroll-to-0 regression in vertical panel - #770

Merged
zonble merged 1 commit into
openvanilla:masterfrom
lukhnos:fix-candidate-ui-regression
Jan 6, 2026
Merged

Fix scroll-to-0 regression in vertical panel#770
zonble merged 1 commit into
openvanilla:masterfrom
lukhnos:fix-candidate-ui-regression

Conversation

@lukhnos

@lukhnos lukhnos commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

In #755 we generalized the math in vertical panel scrolling and synced the code with OpenVanilla, but due to how McBopomofo sets the panel candidate differently, the PR caused a regression in that the vertical panel failed to scroll back to page 0 if a previous candidate selection session moved to a non-zero page.

Postmortem

The generalized math has a code path that does nothing. However, we didn't account for the fact that McBopomofo repeatedly resets the candidate panel's delegate. Resetting delegate reloads the data, but when the delegate is set to nil, there are no actual rows, and the table view's selected row is reset to 0 while the scroll view is still set to where the non-zero page started (this is consistent with Cocoa's behavior). But because the selected row is now reset, when the new candidate data is loaded, the candidate panel thinks that no further action is needed (because it's already set to 0), and so no scrolling is needed. In the previous code, -scrollRowToVisible was always called in this case. We therefore need to make sure that -scrollRowToVisible is always called when the selected candidate index is set to 0.

OpenVanilla is not affected due to how it interacts with the panel's delegate logic, but syncing this change is still desirable.

In openvanilla#755 we generalized the
math in vertical panel scrolling and synced the code with OpenVanilla,
but due to how McBopomofo sets the panel candidate differently, the PR
caused a regression in that the vertical panel failed to scroll back to
page 0 if a previous candidate selection session moved to a non-zero
page.

Postmortem. The generalized math has a code path that does nothing.
However, we didn't account for the fact that McBopomofo repeatedly
resets the candidate panel's delegate. Resetting delegate reloads the
data, but when the delegate is set to nil, there are no actual rows, and
the table view's selected row is reset to 0 while the scroll view is
still set to where the non-zero page started (this is consistent with
Cocoa's behavior). But because the selected row is now reset, when the
new candidate data is loaded, the candidate panel thinks that no further
action is needed (because it's already set to 0), and so no scrolling is
needed. In the previous code, -scrollRowToVisible was always called in
this case. We therefore need to make sure that -scrollRowToVisible is
always called when the selected candidate index is set to 0.

OpenVanilla is not affected due to how it interacts with the panel's
delegate logic, but syncing this change is still desirable.
Copilot AI review requested due to automatic review settings January 5, 2026 22:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a regression in the vertical candidate panel where it failed to scroll to the top. The fix involves ensuring that a scroll to row 0 is always triggered when the selected index is set to 0. The analysis in the pull request description is thorough, and the code change is a direct and correct implementation of the proposed solution. The change is minimal and well-contained, effectively resolving the bug without introducing apparent side effects.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a scroll-to-zero regression introduced in PR #755 where the vertical candidate panel failed to reset its scroll position to page 0 when the delegate was reset after navigating to a non-zero page.

Key Changes

  • Added an explicit check for newRowIndex == 0 to ensure scrollRowToVisible is always called when scrolling to the first row
  • Updated the comment to reflect that scrolling is guaranteed for row 0, not just when never selected or moving by one

@zonble
zonble merged commit 53fc9e0 into openvanilla:master Jan 6, 2026
16 checks passed
@lukhnos
lukhnos deleted the fix-candidate-ui-regression branch January 6, 2026 02:32
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.

3 participants