fix(data-table): keep right-pinned action column header sticky on horizontal scroll#2785
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…izontal scroll The row-actions column is pinned right by injecting `sticky right-0` into the column className, which reaches both body cells and the header cell. Body cells stayed pinned, but the header appended a `relative` (for the resize handle) that — via tailwind-merge — clobbered the injected `sticky`, so the "操作" title scrolled away while its cells stayed frozen. Detect a right-pinned header (className carries `sticky`+`right-0`), skip `relative` for it (a sticky cell is its own positioning context, so the absolute resize handle still anchors), and re-assert `sticky right-0 z-20` after col.className so tailwind-merge keeps the pin above the body cells (z-10). Add a header-`th` sticky assertion to row-action-sticky (the test only covered body `td` — exactly the gap that let this through). Closes #2784 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2784
问题
列表右侧「操作」列固定在右边缘,但只有列身固定、表头没固定。横向滚动时「操作」表头被滚走,而它下面的按钮列还钉在右边 —— 表头与列身错位。左冻结列无此问题。
根因
「操作」列(
_actions)靠往className注入sticky right-0 z-10 …实现右固定,该 className 同时下发给列身单元格与表头单元格:col.cellClassName之后无其他定位类,sticky保留 → 固定 ✅col.className,随后无条件追加relative(给列宽拖拽手柄做定位锚点)。因cn=tailwind-merge,后出现的relative覆盖掉sticky→ 表头不再固定 ❌改动
packages/components/src/renderers/complex/data-table.tsx:表头识别右固定列(className含sticky+right-0),该列不再追加relative(sticky 本身即定位上下文,absolute拖拽手柄仍能锚定),并在col.className之后重声明sticky right-0 z-20(tailwind-merge 保留固定,z 抬到 20 压在列身固定单元格 z-10 之上)。左冻结列/拖拽手柄/非固定列不受影响。packages/plugin-grid/src/__tests__/row-action-sticky.test.tsx:补一条表头th的 sticky 断言 —— 原测试只覆盖列身td,正是这个盲区放走了本 bug。验证
row-action-sticky4/4 通过(含新增表头断言)。/row-actions-preview.html,13 列表格溢出 345px):滚到最右后表头位移 ——操作0px(position:sticky/right:0/z:20)、普通列随内容滚走、名称(左冻结)0px。表头与列身完全同步。🤖 Generated with Claude Code