Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

没有设置 title 的列,展示时表头变成了 td,应该是 th #1066

Closed
RexSkz opened this issue Jan 17, 2024 · 5 comments · Fixed by #1075
Closed

没有设置 title 的列,展示时表头变成了 td,应该是 th #1066

RexSkz opened this issue Jan 17, 2024 · 5 comments · Fixed by #1075
Assignees

Comments

@RexSkz
Copy link

RexSkz commented Jan 17, 2024

CodeSandbox 链接:https://codesandbox.io/p/sandbox/antd-biao-ge-lie-mei-you-title-shi-hui-bian-wei-td-er-fei-forked-yy2x6s?file=%2Fdemo.tsx%3A1%2C1

image

原因是 src/Header/HeaderRow.tsx 里面的 component 字段判断逻辑有误:

<Cell
  component={column.title ? CellComponent : tdCellComponent}
/>

这不但会影响到 title 为空的列,也会影响到 expandable 所在列,因为它大部分情况下也没有 title

@zombieJ
Copy link
Member

zombieJ commented Jan 31, 2024

要 blame 一下为什么这么写,感觉是有意为之

@RexSkz
Copy link
Author

RexSkz commented Jan 31, 2024

引入的 PR 是这个:#859

之前是正常的,这个 PR 专门让上层 HeaderRow 传了个 tdCellComponent 下来,并且在没有设置 title 时使用了它,应该是故意的。

查了一下 WHATWG 没有强制规定 thead 里面必须如何使用 thtd,似乎也没有最佳实践之类的东西,所以我不知道为什么要这么改😂

@zombieJ
Copy link
Member

zombieJ commented Jan 31, 2024

看了一下 https://www.w3.org/WAI/tutorials/tables/irregular/

没有 title 的部分作为 td 使用,但是我感觉 th 似乎还是更合理一些?

@RexSkz
Copy link
Author

RexSkz commented Jan 31, 2024

这个 issue 跟链接中不是同一个场景:

链接里想表达的是:有一种场景叫做“第一列是表头列”。在这种场景下,左上角的单元格没有表头功能,展示为 td 比较合理。不过在 antd 里,这种场景用 rowScope: 'row' 就可以解决了。

没有 title 的表头不一定没有表头功能,例如:

BeforeAfter
12+1
34+1

此外对于 rowSelection,如果设置为 checkbox 则左上角有内容、radio 则没内容,不能因为这个来推断“是否有表头功能”。

@zombieJ
Copy link
Member

zombieJ commented Jan 31, 2024

没有 title 的部分作为 td 使用,但是我感觉 th 似乎还是更合理一些?

我意思就是应该用 th 哈~

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 a pull request may close this issue.

3 participants