Skip to content

fix(ui): let ScrollTo leave the end of a following List - #74

Closed
xiaoyumuxi wants to merge 1 commit into
mainfrom
sync/list-scrollto-leaves-follow
Closed

xiaoyumuxi wants to merge 1 commit into
mainfrom
sync/list-scrollto-leaves-follow

Conversation

@xiaoyumuxi

Copy link
Copy Markdown

关联 Issue:无;上游 PR:vivaui#503

改了什么

把上游 PR vivaui#503 的修复(372a77f9)cherry-pick 到 fork main(8af03952):

  • 跟随末尾的 List 上,ScrollTo 跳到远离末尾的行会脱离末尾,之后新增的行不再把列表拉回末尾;
  • ScrollToEnd 重新跟随末尾。

各层的改动

  • base/list.go(ListArea):
    • 处理滚动请求时,用上一帧声明的 follow 来结算,所以能标记为已脱离;
    • pinned 改为在请求处理之后读取。
  • ui/list_follow_test.go:新增 TestListScrollToLeavesTheEndOfAFollowingList。

为什么

ScrollArea 每帧声明时会先把 follow 清零,要等行之后的 Follow(true) 才恢复。滚动请求恰好在这两次声明之间处理,所以 ScrollTo 永远标不成已脱离,跟随又会把列表拉回末尾。根因的完整说明见上游 PR。

Lithe 的 Agent 对话页(Lithe-IDEA/Lithe-IDEA#2492)里,点提问导航跳到较早的提问时就会碰到这个问题,目前在应用层先关掉跟随再跳转来绕过。这个 PR 合入后升级固定版本,就能删掉那段绕过。

怎么验证的

macOS(Apple Silicon)上运行:

  • 改动文件 gofmt 干净
  • go vet ./base/ ./ui/
  • go test ./ui/ -run 'Follow|ScrollTo|List' -count=1 通过
  • 上游分支上跑过全量 go test ./... -count=1 和平台 vet(windows、linux、wasm、vivahead)。全量里有两组失败与本改动无关,在不含本改动的上游 main 上同样失败:打包测试的部署目标环境问题,以及 input-number 的热绘制分配。
  • 真实窗口:没有跑

边界在哪

框架能力修正:ScrollTo 和 Follow 组合时应与用户滚动的行为一致。

ListArea declares the scroll area before the rows, and ScrollArea forgets
whether the area follows until the Box the List returns says Follow again.
A ScrollTo applied there settled against a state that did not follow, so it
never detached, and the Follow(true) after the rows pulled the list back to
its end. The request now settles against the follow the paint before
declared, and the pinned flag is read after the request is applied.
@xiaoyumuxi

Copy link
Copy Markdown
Author

已被上游 7ac5ef11(vivaui#503)取代:#75 把上游同步进 fork main 后,fork main 已经包含同样的修复,这个 cherry-pick 不再需要。

@xiaoyumuxi xiaoyumuxi closed this Nov 28, 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