-
-
Couldn't load subscription status.
- Fork 620
chore: sync antd 5.x branch to master #1350
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
Changes from all commits
3c278e0
c9d0c5f
eba59a8
8c37e7f
d2eed49
835364f
25fb5a1
523414b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||
| import React from 'react'; | ||||||||||||||
| import Table from 'rc-table'; | ||||||||||||||
|
|
||||||||||||||
| // 示例:使用 measureRowRender 来隐藏 MeasureRow 中的弹层 | ||||||||||||||
| const MeasureRowRenderExample = () => { | ||||||||||||||
| const columns = [ | ||||||||||||||
| { | ||||||||||||||
| title: ( | ||||||||||||||
| <div> | ||||||||||||||
| Name | ||||||||||||||
| <div className="filter-dropdown" style={{ display: 'none' }}> | ||||||||||||||
| Filter Content | ||||||||||||||
| </div> | ||||||||||||||
| </div> | ||||||||||||||
| ), | ||||||||||||||
| dataIndex: 'name', | ||||||||||||||
| key: 'name', | ||||||||||||||
| width: 100, | ||||||||||||||
| }, | ||||||||||||||
| { | ||||||||||||||
| title: 'Age', | ||||||||||||||
| dataIndex: 'age', | ||||||||||||||
| key: 'age', | ||||||||||||||
| width: 80, | ||||||||||||||
| }, | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| const data = [ | ||||||||||||||
| { key: 1, name: 'John', age: 25 }, | ||||||||||||||
| { key: 2, name: 'Jane', age: 30 }, | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| // 自定义 MeasureRow 渲染,隐藏弹层内容 | ||||||||||||||
| const measureRowRender = measureRow => <div style={{ display: 'none' }}>{measureRow}</div>; | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 不要用 测量行需要参与布局才能被 - // 自定义 MeasureRow 渲染,隐藏弹层内容
- const measureRowRender = measureRow => <div style={{ display: 'none' }}>{measureRow}</div>;
+ // 自定义 MeasureRow 渲染,隐藏但仍参与布局,保证可测量
+ const measureRowRender = measureRow => (
+ <div style={{ visibility: 'hidden', pointerEvents: 'none' }}>{measureRow}</div>
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| return ( | ||||||||||||||
| <Table | ||||||||||||||
| columns={columns} | ||||||||||||||
| data={data} | ||||||||||||||
| sticky | ||||||||||||||
| scroll={{ x: true }} | ||||||||||||||
| measureRowRender={measureRowRender} | ||||||||||||||
| /> | ||||||||||||||
| ); | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export default MeasureRowRenderExample; | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,6 +137,34 @@ const data = [ | |
| { a: '1333', c: 'eee', d: 2, key: '20' }, | ||
| ]; | ||
|
|
||
| const columns3: ColumnType<RecordType>[] = [ | ||
| { title: '', dataIndex: 'name', key: '0' }, | ||
| { title: 'First column', dataIndex: 'name', key: '1' }, | ||
| { title: 'Second column', dataIndex: 'address', key: '2' }, | ||
| { title: 'Third column', dataIndex: 'age', key: '3' }, | ||
| { title: 'Another column', dataIndex: 'address', key: '4' }, | ||
| { title: 'Extra column', dataIndex: 'name', key: '5' }, | ||
| { title: 'And yet another column', dataIndex: 'address', key: '6' }, | ||
| { | ||
| title: 'Column 7 with extraaaaaaaaa long word', | ||
| dataIndex: 'age', | ||
| key: '7', | ||
| }, | ||
| { title: 'Column 8', dataIndex: 'address', key: '8' }, | ||
| { title: 'Column 9', dataIndex: 'name', key: '9' }, | ||
| { title: 'Column 10', dataIndex: 'address', key: '10' }, | ||
| { title: 'Column 11', dataIndex: 'address', key: '11' }, | ||
| { title: 'Column 12', dataIndex: 'age', key: '12' }, | ||
| { title: 'Column 13', dataIndex: 'address', key: '13' }, | ||
| { title: 'Column 14', dataIndex: 'name', key: '14' }, | ||
| { title: 'Column 15', dataIndex: 'address', key: '15' }, | ||
| { title: 'Column 16', dataIndex: 'address', key: '16' }, | ||
| { title: 'Column 17', dataIndex: 'name', key: '17' }, | ||
| { title: 'Column 18', dataIndex: 'address', key: '18' }, | ||
| { title: 'Column 19', dataIndex: 'address', key: '19' }, | ||
| { title: 'Column 20', dataIndex: 'age', key: '20' }, | ||
| ]; | ||
|
|
||
| const Demo = () => { | ||
| const container = useRef(); | ||
| return ( | ||
|
|
@@ -274,7 +302,7 @@ const Demo = () => { | |
| <br /> | ||
| <Table | ||
| columns={fixedColumns} | ||
| data={[{}]} | ||
| data={[{ key: '1' }]} | ||
| scroll={{ | ||
| x: 'max-content', | ||
| }} | ||
|
|
@@ -283,7 +311,7 @@ const Demo = () => { | |
| <br /> | ||
| <Table | ||
| columns={columnsWithWidth} | ||
| data={[{}]} | ||
| data={[{ key: '1' }]} | ||
| scroll={{ | ||
| x: 1200, | ||
| }} | ||
|
|
@@ -301,7 +329,7 @@ const Demo = () => { | |
| <br /> | ||
| <Table | ||
| columns={fixedColumns.map(column => ({ ...column, width: undefined }))} | ||
| data={[{}]} | ||
| data={[{ key: '1' }]} | ||
| scroll={{ | ||
| x: 'max-content', | ||
| }} | ||
|
|
@@ -310,12 +338,26 @@ const Demo = () => { | |
| <br /> | ||
| <Table | ||
| columns={columnsGrouped} | ||
| data={[{}, {}]} | ||
| data={[{ key: '1' }, { key: '2' }]} | ||
| scroll={{ | ||
| x: 'max-content', | ||
| }} | ||
| sticky | ||
| /> | ||
| <br /> | ||
| <h3>scroll.x is true</h3> | ||
| <p>https://github.com/ant-design/ant-design/issues/54894</p> | ||
| <Table | ||
| columns={columns3} | ||
| data={ | ||
| [ | ||
| { key: '1', name: 'Test', age: 1, address: '2' }, | ||
| { key: '2', name: '0', age: 1, address: '2' }, | ||
| ] as any | ||
| } | ||
|
Comment on lines
+352
to
+357
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
|
||
| sticky | ||
| scroll={{ x: true }} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,7 +36,7 @@ export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> { | |||||||||||||||||||||||||
| stickyTopOffset?: number; | ||||||||||||||||||||||||||
| stickyBottomOffset?: number; | ||||||||||||||||||||||||||
| stickyClassName?: string; | ||||||||||||||||||||||||||
| scrollTableStyle?: React.CSSProperties; | ||||||||||||||||||||||||||
| scrollX?: number | string | true; | ||||||||||||||||||||||||||
| tableLayout?: TableLayout; | ||||||||||||||||||||||||||
| onScroll: (info: { currentTarget: HTMLDivElement; scrollLeft?: number }) => void; | ||||||||||||||||||||||||||
| children: (info: HeaderProps<RecordType>) => React.ReactNode; | ||||||||||||||||||||||||||
|
|
@@ -61,7 +61,7 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | |||||||||||||||||||||||||
| stickyTopOffset, | ||||||||||||||||||||||||||
| stickyBottomOffset, | ||||||||||||||||||||||||||
| stickyClassName, | ||||||||||||||||||||||||||
| scrollTableStyle, | ||||||||||||||||||||||||||
| scrollX, | ||||||||||||||||||||||||||
| tableLayout = 'fixed', | ||||||||||||||||||||||||||
| onScroll, | ||||||||||||||||||||||||||
| maxContentScroll, | ||||||||||||||||||||||||||
|
|
@@ -197,8 +197,9 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro | |||||||||||||||||||||||||
| <TableComponent | ||||||||||||||||||||||||||
| style={{ | ||||||||||||||||||||||||||
| tableLayout, | ||||||||||||||||||||||||||
| visibility: noData || mergedColumnWidth ? null : 'hidden', | ||||||||||||||||||||||||||
| ...scrollTableStyle, | ||||||||||||||||||||||||||
| minWidth: '100%', | ||||||||||||||||||||||||||
| // https://github.com/ant-design/ant-design/issues/54894 | ||||||||||||||||||||||||||
| width: scrollX, | ||||||||||||||||||||||||||
afc163 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||
|
Comment on lines
+200
to
203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 严重: 当 <TableComponent
style={{
tableLayout,
minWidth: '100%',
// https://github.com/ant-design/ant-design/issues/54894
- width: scrollX,
+ width: scrollX === true ? 'auto' : scrollX,
}}
>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||
| {colGroupNode} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of
word-break: break-word;could lead to layout issues where long words in table cells overflow their containers. It's advisable to re-introduce word wrapping. Consider usingoverflow-wrap: break-word;, which is the current standard for this purpose.