diff --git a/assets/index.less b/assets/index.less index bfa245b03..ef38409d3 100644 --- a/assets/index.less +++ b/assets/index.less @@ -44,7 +44,6 @@ padding: @cell-padding; white-space: normal; - word-break: break-word; border: @border; border-top: 0; border-left: 0; diff --git a/docs/examples/scrollY.tsx b/docs/examples/scrollY.tsx index 52622db5f..d9acf52eb 100644 --- a/docs/examples/scrollY.tsx +++ b/docs/examples/scrollY.tsx @@ -76,6 +76,9 @@ const Test = () => { rowKey={record => record.key} onRow={(record, index) => ({ style: { backgroundColor: 'red' } })} /> +

Column align issue

+

https://github.com/ant-design/ant-design/issues/54889

+ ); }; diff --git a/docs/examples/stickyHeader.tsx b/docs/examples/stickyHeader.tsx index 52f285675..a004c1dba 100644 --- a/docs/examples/stickyHeader.tsx +++ b/docs/examples/stickyHeader.tsx @@ -137,6 +137,34 @@ const data = [ { a: '1333', c: 'eee', d: 2, key: '20' }, ]; +const columns3: ColumnType[] = [ + { 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 = () => {
{
{
({ ...column, width: undefined }))} - data={[{}]} + data={[{ key: '1' }]} scroll={{ x: 'max-content', }} @@ -310,12 +338,26 @@ const Demo = () => {
+
+

scroll.x is true

+

https://github.com/ant-design/ant-design/issues/54894

+
); }; diff --git a/src/ColGroup.tsx b/src/ColGroup.tsx index 6c49f304f..95b9a839d 100644 --- a/src/ColGroup.tsx +++ b/src/ColGroup.tsx @@ -40,7 +40,7 @@ function ColGroup({ colWidths, columns, columCount }: ColGroupProps< } } - return {cols}; + return cols.length > 0 ? {cols} : null; } export default ColGroup; diff --git a/src/FixedHolder/index.tsx b/src/FixedHolder/index.tsx index 09e4598b1..c7513894b 100644 --- a/src/FixedHolder/index.tsx +++ b/src/FixedHolder/index.tsx @@ -34,7 +34,7 @@ export interface FixedHeaderProps extends HeaderProps { 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) => React.ReactNode; @@ -60,7 +60,7 @@ const FixedHolder = React.forwardRef>((pro stickyTopOffset, stickyBottomOffset, stickyClassName, - scrollTableStyle, + scrollX, tableLayout = 'fixed', onScroll, children, @@ -179,7 +179,9 @@ const FixedHolder = React.forwardRef>((pro style={{ tableLayout, visibility: noData || mergedColumnWidth ? null : 'hidden', - ...scrollTableStyle, + minWidth: '100%', + // https://github.com/ant-design/ant-design/issues/54894 + width: scrollX, }} > {colGroupNode} diff --git a/src/Table.tsx b/src/Table.tsx index 0a3c9a1ac..7a2ca550a 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -684,7 +684,7 @@ function Table( ...columnContext, direction, stickyClassName, - scrollTableStyle, + scrollX: mergedScrollX, tableLayout: mergedTableLayout, onScroll: onInternalScroll, }; diff --git a/tests/__snapshots__/ExpandRow.spec.jsx.snap b/tests/__snapshots__/ExpandRow.spec.jsx.snap index 5c0ee296d..494f6d92d 100644 --- a/tests/__snapshots__/ExpandRow.spec.jsx.snap +++ b/tests/__snapshots__/ExpandRow.spec.jsx.snap @@ -14,7 +14,6 @@ LoadedCheerio {
- @@ -519,7 +518,6 @@ LoadedCheerio {
- @@ -861,7 +859,6 @@ LoadedCheerio {
- @@ -996,7 +993,6 @@ LoadedCheerio {
- diff --git a/tests/__snapshots__/FixedColumn.spec.tsx.snap b/tests/__snapshots__/FixedColumn.spec.tsx.snap index 621fd9255..56f99b870 100644 --- a/tests/__snapshots__/FixedColumn.spec.tsx.snap +++ b/tests/__snapshots__/FixedColumn.spec.tsx.snap @@ -1941,7 +1941,7 @@ LoadedCheerio { style="overflow: hidden;" >
shadow should be shown when there are columns where style="overflow: hidden;" >
shadow should be shown when there are columns where
- @@ -5567,7 +5566,7 @@ exports[`Table.FixedColumn > shadow should display correctly 1`] = ` style="overflow: hidden;" >
shadow should display correctly 2`] = ` style="overflow: hidden;" >
- @@ -120,7 +119,6 @@ LoadedCheerio { name="my-table" style="table-layout: auto;" > -
- -
- @@ -567,7 +562,6 @@ LoadedCheerio {
- @@ -660,7 +654,6 @@ LoadedCheerio {
- @@ -746,7 +739,6 @@ LoadedCheerio {
- @@ -832,7 +824,6 @@ LoadedCheerio {
- @@ -930,7 +921,6 @@ LoadedCheerio {
- @@ -1016,7 +1006,6 @@ LoadedCheerio {
- @@ -1095,7 +1084,6 @@ LoadedCheerio {
- @@ -1192,7 +1180,7 @@ LoadedCheerio { style="overflow: hidden;" >
-