fix(chat): hide stale scroll-to-bottom button after dock close(#270) - #304
Open
chujieHong wants to merge 1 commit into
Open
fix(chat): hide stale scroll-to-bottom button after dock close(#270)#304chujieHong wants to merge 1 commit into
chujieHong wants to merge 1 commit into
Conversation
A layout clamp (dock open/close, content shrink) can rewrite scrollTop to the bottom without a user gesture. Previously this could leave free mode active with a stale jump-to-bottom control while the user is pinned to the bottom, or surface the control after the dock interaction with no correction. - Pass gapToBottom + atBottomBandPx to shouldEnterFreeModeOnScrollUp so a scroll-up whose resulting position stays inside the bottom band is treated as a layout clamp, not user intent. - Re-check position on scroll-up and after resize in free mode: landing inside the bottom band resumes follow mode and hides the control.
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.
背景
聊天页查看历史时,点开/关闭"编辑文件" dock 后,用户其实还在底部,却出现残留的 ↓ 回到底部按钮;点击它反而会轻微上移。
issue链接:#270
根因
关闭 dock 导致 viewport 变大,浏览器会把 scrollTop 重写到底部(clamp),却不触发用户滚动意图。旧的逻辑:
shouldEnterFreeModeOnScrollUp只按 upDelta 判断,把这种"钳制回底"当成用户上滑 → 进 free 模式、显示 ↓;handleResize在 free 模式下无条件显示 ↓,没有任何后续事件纠正。修复
shouldEnterFreeModeOnScrollUp新增gapToBottom+atBottomBandPx参数:上滑结果落在底部带内(≤12px)视为布局钳制,而非用户意图,不进 free 模式。handleScroll上滑分支重查位置:落在底部带内直接恢复 follow、隐藏 ↓。handleResizefree 模式分支重查位置:布局变化后仍在底部带内 → 恢复 follow;真正离开底部才保留 ↓。测试
scrollFreeMode测试(钳制 vs 真上滑区分)+ 3 条useAutoScroll集成测试(dock 开关 cycle、free 模式钳制回底、sticky zone 上滑)。tsc --noEmit通过;实际验证 bug 消失。