fix(Console): auto-scroll disengages on output#1823
Open
v1ne wants to merge 1 commit intofluidd-core:developfrom
Open
fix(Console): auto-scroll disengages on output#1823v1ne wants to merge 1 commit intofluidd-core:developfrom
v1ne wants to merge 1 commit intofluidd-core:developfrom
Conversation
8eb5224 to
cb5471b
Compare
cb5471b to
448182c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to fix sporadic console auto-scroll disengagement (#1783) by distinguishing user-driven scrolls from programmatic scroll adjustments triggered by vue-virtual-scroller item measurement.
Changes:
- Adds a “programmatic scroll window” (rAF frame counter) to ignore scroll events that are caused by internal scrollTop adjustments.
- Hooks into
DynamicScrollerinternals (vscrollData.sizes) to detect upcoming measurement-driven scroll adjustments and pre-mark them as programmatic. - Reworks the scroll pause/unpause logic to only pause on non-latest, non-programmatic scrolls, and to resume when the view returns to latest output.
|
|
||
| <script lang="ts"> | ||
| import { Component, Prop, Mixins, Watch, Ref, PropSync } from 'vue-property-decorator' | ||
| import consola from 'consola' |
Comment on lines
+119
to
+131
| // DynamicScroller's internal `itemsWithSize` watcher adjusts scrollTop on item | ||
| // measurement, producing a scroll event indistinguishable from user input. | ||
| // Mirror vscrollData.sizes so we can open a programmatic window before that event. | ||
| const scroller = this.dynamicScroller as unknown as { | ||
| vscrollData?: { sizes: Record<string | number, number> } | ||
| } | ||
| const vscrollData = scroller.vscrollData | ||
| if (vscrollData) { | ||
| this._stopSizesWatcher = this.$watch( | ||
| () => vscrollData.sizes, | ||
| () => this.markProgrammatic(), | ||
| { deep: true } | ||
| ) |
Author
There was a problem hiding this comment.
I am open for any cheaper solution that actually works. But there is no public API on the scroller to support this.
Comment on lines
+170
to
+182
| markProgrammatic (frames = 2) { | ||
| this._programmaticFrames = Math.max(this._programmaticFrames, frames) | ||
| if (this._programmaticRaf === null) { | ||
| const tick = () => { | ||
| this._programmaticFrames-- | ||
| if (this._programmaticFrames > 0) { | ||
| this._programmaticRaf = requestAnimationFrame(tick) | ||
| } else { | ||
| this._programmaticRaf = null | ||
| } | ||
| } | ||
| }) | ||
| this._programmaticRaf = requestAnimationFrame(tick) | ||
| } |
The original onScroll delegated to updateScrollingPaused() with no way to distinguish user input from DynamicScroller's internal scrollTop corrections. Appending a line triggers item measurement, which causes DynamicScroller's itemsWithSize watcher to rewrite scrollTop; the resulting scroll event would falsely pause auto-scroll if the view was momentarily off-bottom. The fix introduces a frame counter primed by watching vscrollData.sizes, the same reactive store itemsWithSize observes. Because Vue 2 flushes watchers in ascending creation-ID order, this watcher always fires before the correction's scroll event arrives as a macrotask, so the programmatic window is guaranteed to be open when onScroll runs. onScroll then only pauses when no programmatic window is active and the view is not at the latest position, a state reachable only via native scrollbar input, which produces no pointer events. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Dennis Schneider <v1ne2go@gmail.com>
f4adc67 to
db949e5
Compare
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.
Better detect the origin of a scroll event to, by making use of how the virtual scroller works. It is not nice, but it works. Fixes #1783