AAswordman / AAswordman/Operit

[可滚动列表(LazyColumn/设置页)在点击触发状态更新后滚动位置重置到顶部

Open
#709 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Already-plan area:ui-layout UI-UX
Dominant language
Kotlin
Stars
7.9k
Forks
651
Avg merge
1d 9h
Merged PRs (30d)
70

Description

问题描述

在多个使用可滚动列表的界面中,当用户滚动到列表中部、点击某个条目触发状态更新(重组)后,列表滚动位置会被重置回顶部,需要重新滚动才能回到刚才的位置。

复现路径

稳定复现于以下场景:

  1. 编辑 System Prompt:滚动到中部,点击文本区域准备编辑 → 页面回顶(光标确实停在点击处,但视图跳回顶部)
  2. 世界书条目编辑:同上
  3. ToolPkg 的 Compose DSL LazyColumn:滚动到中部,点击条目切换状态/编辑 → 回顶

期望行为

状态更新(重组)后,列表应保持当前滚动位置,而不是重置到顶部。

技术分析

在 ToolPkg 的 Compose DSL 侧,LazyColumnProps 仅暴露 contentspacing,没有任何滚动状态相关的 API(如 scrollState / rememberLazyListState / initialFirstVisibleItemIndex)。即使为每个 item 设置稳定的 key,重组后滚动位置仍会丢失。

由于系统内置的 Prompt / 世界书设置页也有同样表现,推测根因在宿主的 Compose 渲染层——列表的 LazyListState 可能在每次重组时被重新创建,而非通过 rememberSaveable 持久化。

环境

  • Android
  • 复现于系统设置页与 ToolPkg Compose DSL 自定义 UI

建议

  1. 宿主侧:为可滚动列表使用 rememberSaveable { rememberLazyListState() } 保持滚动位置
  2. DSL 侧:为 LazyColumnProps 暴露可选的滚动状态保持能力(例如 preserveScrollPosition 或允许传入 stateKey)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing LazyColumnState creation in the host Compose rendering layer and reviewing LazyColumnProps in the ToolPkg Compose DSL. Reproduce the System Prompt, world-book, and ToolPkg cases, then verify that state updates preserve the current scroll position in each view.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.