Repository navigation
feat: 表头吸顶 (Sticky Header) 功能及配套 - #3323
Conversation
|
你好 @Alexzjt,非常感谢你的贡献. Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes. |
Summary of ChangesHello @Alexzjt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求引入了 @antv/s2 的完整表头吸顶功能,解决了大型表格在长页面滚动时表头易丢失的问题。通过双实例架构和 DOM 代理,实现了表头在滚动时吸附在视口顶部,并支持丰富的交互操作。这一改进显著提升了用户在浏览长表格数据时的体验,确保了列信息的持续可见性和可操作性。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #3323 +/- ##
==========================================
+ Coverage 75.77% 78.66% +2.89%
==========================================
Files 257 224 -33
Lines 11994 12485 +491
Branches 2464 2836 +372
==========================================
+ Hits 9088 9821 +733
+ Misses 1398 957 -441
- Partials 1508 1707 +199 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
本次 PR 实现了表头吸顶(Sticky Header)功能,这是一个非常实用的特性,尤其对于大数据量表格。整体实现方案采用了双 S2 实例的架构,考虑了滚动容器、交互桥接、性能优化(数据精简)等多个方面,代码质量很高。
我主要提出了几点小建议:
- 在
sticky-header/index.ts中有一处重复的 JSDoc 注释,建议移除。 - 在
sticky-header.ts示例代码中,建议移除不必要的as any类型断言和未使用的SpreadSheet导入,以提升代码的类型安全性和整洁度。
除此之外,代码逻辑清晰,考虑周全,是一次出色的功能增强。
|
Size Change: +1.98 kB (+0.27%) Total Size: 744 kB
ℹ️ View Unchanged
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This PR introduces a sticky header feature for the @antv/s2 library, which significantly enhances the user experience for large data tables by keeping the header visible during scrolling. The implementation utilizes a complex but effective dual-instance architecture, demonstrating clear code structure and robust handling of secondary instance lifecycles, state synchronization, and interaction bridging. While no security vulnerabilities were identified, and the code adheres to secure coding practices, a potential bug was found in the data minimization logic that could lead to incorrect header rendering in certain edge cases. Overall, this is a high-quality contribution.
|
/gemini review |
There was a problem hiding this comment.
Code Review
本次 PR 引入了表头吸顶(Sticky Header)功能,这是一个非常实用的特性,极大地提升了大数据量表格的用户体验。整体实现方案非常出色,采用了双实例架构来隔离主表和吸顶表头,思路清晰,代码结构合理。
主要亮点包括:
StickyHeaderController设计良好:将吸顶相关的逻辑(DOM 操作、状态管理、滚动监听)都封装在独立的控制器中,易于维护。- 性能优化考虑周全:通过
minimizeDataCfg减少吸顶表头实例的数据量,并使用throttle来优化滚动事件处理,这些都是很好的性能实践。 - 交互桥接设计巧妙:通过事件转发机制,实现了吸顶状态下表头交互(如排序、Resize)与主表的联动,保证了功能的一致性。
- 兼容性好:代码中细致地处理了
window滚动和父容器滚动两种场景,并考虑了不同定位方式(fixedvsabsolute),增强了功能的适用性。
代码质量很高,仅有一个关于增强代码健壮性的微小建议。总体来说,这是一次高质量的功能提交。
|
🎉 This PR is included in version @antv/s2-v2.7.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version @antv/s2-v2.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* feat: 表头吸顶 init * fix: 修复已知问题,增加官网案例 * chore: 修复案例异常 * feat: 表头吸顶支持部分交互 * chore: 修复 CR 意见 * fix: 修复 CR 问题
👀 PR includes
✨ Feature
🎨 Enhance
🐛 Bugfix
🔧 Chore
📝 Description
背景与解决的问题:
大型表格在长页面滚动时,用户往往希望表头能够吸附在屏幕顶部,以便在向下滚动查看数据时依然能够清晰识别列的含义。本项目此前缺乏在
window/body层级滚动时的外部表头吸顶能力。主要改动点:
本 PR 为
@antv/s2带来了完整的表头吸顶 (Sticky Header) 功能及配套交互:interaction.stickyHeader,并支持自定义offsetTop(适配存在顶部导航栏的系统)。enableInteraction):RANGE_SORT)、树节点及角头全量展开/折叠(ROW_CELL_COLLAPSED)。scroll-loop.ts),包含 React Playground 案例支持。🖼️ Screenshot
🔍 Self-Check before the merge