feat: support raw list sticky sections#46
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
总体说明本 PR 对 Listy 列表组件进行了深度架构重构,将原先在单个
改动概览
序列图sequenceDiagram
participant App as 应用层
participant Listy as Listy<br/>薄包装
participant RawList as RawList<br/>普通列表
participant VirtualList as VirtualList<br/>虚拟列表
participant RcVirtualList as rc-virtual-list<br/>底层库
App->>Listy: props(virtual=false)
Listy->>RawList: 分发
RawList->>App: 暴露 scrollTo
App->>Listy: props(virtual=true)
Listy->>VirtualList: 分发
VirtualList->>RcVirtualList: 配置虚拟化
VirtualList->>App: 暴露 scrollTo
审核要点
总览本 PR 重构列表组件的内部架构,将单体 List.tsx 拆解为 RawList(普通列表)与 VirtualList(虚拟列表)两个独立实现,由 List 作为薄包装层根据 改动概览组件架构重构
🎯 3 (Moderate) | ⏱️ ~25 分钟 可能相关的 PR
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
docs/examples/basic.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. docs/examples/no-virtual.tsxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. src/GroupHeader.tsxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
===========================================
+ Coverage 98.94% 100.00% +1.05%
===========================================
Files 5 8 +3
Lines 95 201 +106
Branches 23 55 +32
===========================================
+ Hits 94 201 +107
+ Misses 1 0 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces a non-virtualized list implementation through the new RawList component, which is used when the virtual prop is set to false. It also optimizes the sticky header logic by replacing a linear search with a binary search for finding the active header index. Review feedback suggests preventing runtime warnings by ensuring refs are not attached to React.Fragment and improving performance by using the mapping function within Array.from when rendering grouped data.
| registerElement(key, rowIndex, element); | ||
| }; | ||
|
|
||
| if (React.isValidElement(node)) { |
There was a problem hiding this comment.
Attaching a ref to a React.Fragment will result in a runtime warning and the ref will not be attached, which would break the scrollTo functionality for that item. It is safer to check if the element is a Fragment before attempting to clone it with a ref.
| if (React.isValidElement(node)) { | |
| if (React.isValidElement(node) && node.type !== React.Fragment) { |
| let rowIndex = 0; | ||
| const rawContent = group | ||
| ? Array.from(groupData).map(([groupKey, groupItems]) => { | ||
| const headerRow = { type: 'header', groupKey } as Row<T, K>; |
There was a problem hiding this comment.
| })} | ||
| </section> | ||
| ); | ||
| }) |
a49095e to
c69d6cc
Compare
Summary
virtual={false}that renders grouped content as section blocks@rc-component/virtual-list, with shared list props for both pathsscrollToby item key and group key across virtual and raw list modesChecks
bun run lintbunx tsc --noEmitbun run compilebun run test -- --coverageut test -- --runInBandSummary by CodeRabbit
发行说明
新增功能
改进
依赖更新