Repository navigation
fix: keep the review sidebar scroll steady when selecting a thread - #4
Closed
petergaultney wants to merge 2 commits into
Closed
petergaultney wants to merge 2 commits into
petergaultney wants to merge 2 commits into
Conversation
Selecting a thread, from a card or from its anchor in the note, rebuilds the sidebar with root.empty(), which collapses the scroller and resets scrollTop to 0. The rebuilt list then either stayed at the top (the lastScrolledItemId guard skipped the re-scroll when the same card was selected twice in one click) or parked the card at the bottom edge of the viewport (scrollIntoView "nearest" from 0). Restore scrollTop after the rebuild so the viewport only moves when the selected card is actually out of view. Scroll to the card the user picked, not the first selected-looking card in document order: a card under the editor cursor also renders as selected, and used to win the scroll target.
Two cards can render as selected at once: the one the user clicked (or reached from its anchor in the note) and the one under the editor cursor. Give the picked card an accent-colored spine and border so it stands apart from the cursor's card.
petergaultney
marked this pull request as ready for review
September 19, 2026 14:32
Member
|
Thanks, Peter. I incorporated this work into Relay Comments 0.3.0 and credited you in the release notes.
These changes are available in the 0.3.0 release. I took the changes onto main rather than merging this branch directly because the surrounding sidebar code had changed in parallel. I’m closing this as incorporated. Thanks again for the careful diagnosis and implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🍋: drafted by a lemon from the debugging session; Peter reviewed the behavior in Obsidian.
On 0.2.1, clicking a commented highlight in the note, or a card in the sidebar, made the sidebar flash and end up somewhere other than the clicked thread - usually the top of the list. In a note with ~10 threads this made replying a two-step hunt: click the card, lose it, scroll to find it again.
Measured over CDP in Obsidian (Electron
--remote-debugging-port), wrappingrender()and samplingcontentEl.scrollTop, the cause is that everyrender()rebuilds the sidebar withroot.empty(). Emptying the scroller collapses it and resetsscrollTopto 0 before the new content exists. From there two things went wrong:locateItem->locateReviewRange->refreshReviewSidebars, thenlocateItem's ownrender()). ThelastScrolledItemIdguard skipped the re-scroll on the second render because the same card was still selected, so the list stayed at 0. That's the "scrolls to the top".scrollIntoView({block: "nearest"})from 0 parks the card at the bottom edge of the viewport rather than where it was, so every click moved the list by a few hundred pixels.Changes
renderContentsavesscrollTopbeforeroot.empty()and restores it after the body is built, then callsscrollIntoViewon the selected card. The viewport only moves when the selected card is actually out of view.lastScrolledItemIdis gone;nearestis already a no-op for a visible card.selectedItemId(the card the user picked) over the cursor-derived selection.critic-card-current, which colors its spine and border with--interactive-accent. The cursor's card keeps the existing softercritic-card-selectedlook, so the two are distinguishable when both are shown.Measured after the change: clicking a card positioned 20px from the top leaves
scrollTopunchanged and the card at 20px; clicking an anchor in the note scrolls the sidebar so the matching card is in view, withselectedItemIdand the scrolled-to card agreeing.No changelog file in the repo, so none updated. 178 unit tests pass.