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

feat: columnResizable #1106

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

linxianxi
Copy link
Contributor

@linxianxi linxianxi commented Apr 8, 2024

rfc: ant-design/ant-design#48152

原先内部 onColumnResize 重命名为 onColumnWidthChange,进行区分

Copy link

vercel bot commented Apr 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
table ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2024 7:19am

README.md Outdated
@@ -132,6 +133,7 @@ React.render(<Table columns={columns} data={data} />, mountNode);
| fixed | String \| Boolean | | this column will be fixed when table scroll horizontally: true or 'left' or 'right' |
| align | String | | specify how cell content is aligned |
| ellipsis | Boolean | | specify whether cell content be ellipsized |
| resizable | Boolean \| { minWidth?: number } | | column resize config |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是这样子的话,我感觉 columnResizable 这个属性都不需要了。column.resizable 控制粒度更小,反而更好。另外 minWidth 不用放 resizable 里,直接是 column.minWidth 就够了。这个属性平时用也是很不错的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样的话,每列都要加一遍,虽然可以 map 加过去,但是还是太麻烦。这个 minWidth 在 resizable 没开启时是什么行为?(现在 antd Table 没设置横向滚动时,父容器缩小,列也会跟着缩小)

Copy link
Contributor Author

@linxianxi linxianxi Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columnResizable 已移除。如果改成 column.minWidth,比如没开启 scroll 时,浏览器宽度缩小,列宽度都会自动缩小的,这个没办法。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没开启 resizable 时,这个 minWidth 感觉没用。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columnResizable 已移除。如果改成 column.minWidth,比如没开启 scroll 时,浏览器宽度缩小,列宽度都会自动缩小的,这个没办法。

这个 OK 的,能添加 minWidth 就行了。再多的就是游览器的限制了

Copy link
Contributor Author

@linxianxi linxianxi Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这个 column.minWidth 其实就只是在 resizable 开启时有用了,其它时候就算写了也是没用的,minWidth 只支持 number 类型吧?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有用的,如果多个设置 minWidth,剩余的不设置。设置的最小宽度就定下了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没看懂。minWidth 应该是可以先在这个之前单独一个版本加这个功能,先跟 resizable 无关。

问题:那这时 minWidth 根本没有场景啊,都没有 resizable 的功能。比如浏览器 resize 导致 Table 缩小了宽度,列的宽度自动会被缩小,没办法限制,这个 minWidth 应该设置了也没用?

src/Table.tsx Outdated Show resolved Hide resolved
src/Cell/index.tsx Outdated Show resolved Hide resolved
@zombieJ
Copy link
Member

zombieJ commented Apr 23, 2024

体验有点怪异,如果是超出 width 的时候缩小应该就是缩小,不应该把右边的撑开才对。

@zombieJ
Copy link
Member

zombieJ commented May 10, 2024

看起来好像没对齐

截屏2024-05-10 13 56 36

@linxianxi
Copy link
Contributor Author

看起来好像没对齐

截屏2024-05-10 13 56 36

故意放在最右侧左边的,没有放在最右侧中间。因为可能会因为 ellipsis 设置造成 超出部分不显示

Copy link

codecov bot commented May 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.06%. Comparing base (fb65b78) to head (875626c).
Report is 1 commits behind head on master.

❗ Current head 875626c differs from pull request most recent head e8dbe01. Consider uploading reports for the commit e8dbe01 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1106      +/-   ##
==========================================
+ Coverage   97.97%   98.06%   +0.09%     
==========================================
  Files          51       53       +2     
  Lines        4681     4913     +232     
  Branches      595      627      +32     
==========================================
+ Hits         4586     4818     +232     
  Misses         91       91              
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 this pull request may close these issues.

None yet

3 participants