Skip to content

fix(chat): hide stale scroll-to-bottom button after dock close(#270) - #304

Open
chujieHong wants to merge 1 commit into
TencentCloud:developfrom
chujieHong:fix/chat-stale-scroll-to-bottom-button
Open

fix(chat): hide stale scroll-to-bottom button after dock close(#270)#304
chujieHong wants to merge 1 commit into
TencentCloud:developfrom
chujieHong:fix/chat-stale-scroll-to-bottom-button

Conversation

@chujieHong

@chujieHong chujieHong commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

背景

聊天页查看历史时,点开/关闭"编辑文件" dock 后,用户其实还在底部,却出现残留的 ↓ 回到底部按钮;点击它反而会轻微上移。
issue链接:#270

根因

关闭 dock 导致 viewport 变大,浏览器会把 scrollTop 重写到底部(clamp),却不触发用户滚动意图。旧的逻辑:

  • shouldEnterFreeModeOnScrollUp 只按 upDelta 判断,把这种"钳制回底"当成用户上滑 → 进 free 模式、显示 ↓;
  • handleResize 在 free 模式下无条件显示 ↓,没有任何后续事件纠正。

修复

  • shouldEnterFreeModeOnScrollUp 新增 gapToBottom + atBottomBandPx 参数:上滑结果落在底部带内(≤12px)视为布局钳制,而非用户意图,不进 free 模式。
  • handleScroll 上滑分支重查位置:落在底部带内直接恢复 follow、隐藏 ↓。
  • handleResize free 模式分支重查位置:布局变化后仍在底部带内 → 恢复 follow;真正离开底部才保留 ↓。

测试

  • 新增 6 条 scrollFreeMode 测试(钳制 vs 真上滑区分)+ 3 条 useAutoScroll 集成测试(dock 开关 cycle、free 模式钳制回底、sticky zone 上滑)。
  • 全部 26 条相关测试通过;tsc --noEmit 通过;实际验证 bug 消失。

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.
@chujieHong chujieHong changed the title fix(chat): hide stale scroll-to-bottom button after dock close fix(chat): hide stale scroll-to-bottom button after dock close(#270) Aug 14, 2026
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.

1 participant