diff --git a/assets/index.less b/assets/index.less index 48df6a791..3205475db 100644 --- a/assets/index.less +++ b/assets/index.less @@ -90,6 +90,18 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + + // Fixed first or last should special process + &.@{tablePrefixCls}-cell-fix-left-last, + &.@{tablePrefixCls}-cell-fix-right-first { + overflow: visible; + + .@{tablePrefixCls}-cell-content { + overflow: hidden; + text-overflow: ellipsis; + display: block; + } + } } } diff --git a/examples/fixedColumns.tsx b/examples/fixedColumns.tsx index 8f14a487b..88f86989c 100644 --- a/examples/fixedColumns.tsx +++ b/examples/fixedColumns.tsx @@ -13,7 +13,7 @@ interface RecordType { const columns: ColumnType[] = [ { title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' }, - { title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left' }, + { title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left', ellipsis: true }, { title: 'title3', dataIndex: 'c', key: 'c' }, { title: 'title4', dataIndex: 'b', key: 'd' }, { title: 'title5', dataIndex: 'b', key: 'e' }, @@ -39,7 +39,12 @@ const columns: ColumnType[] = [ ]; const data: RecordType[] = [ - { a: '123', b: 'xxxxxxxx', d: 3, key: '1' }, + { + a: '123', + b: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + d: 3, + key: '1', + }, { a: 'cdd', b: 'edd12221', d: 3, key: '2' }, { a: '133', c: 'edd12221', d: 2, key: '3' }, { a: '133', c: 'edd12221', d: 2, key: '4' }, diff --git a/src/Cell/index.tsx b/src/Cell/index.tsx index 43a129f82..3abc171bc 100644 --- a/src/Cell/index.tsx +++ b/src/Cell/index.tsx @@ -76,6 +76,8 @@ function Cell( }: CellProps, ref: React.Ref, ): React.ReactElement { + const cellPrefixCls = `${prefixCls}-cell`; + // ==================== Child Node ==================== let cellProps: CellType; let childNode: React.ReactNode; @@ -104,6 +106,10 @@ function Cell( childNode = null; } + if (ellipsis && (lastFixLeft || firstFixRight)) { + childNode = {childNode}; + } + const { colSpan: cellColSpan, rowSpan: cellRowSpan } = cellProps || {}; const mergedColSpan = cellColSpan !== undefined ? cellColSpan : colSpan; const mergedRowSpan = cellRowSpan !== undefined ? cellRowSpan : rowSpan; @@ -142,8 +148,6 @@ function Cell( } } - const cellPrefixCls = `${prefixCls}-cell`; - const componentProps = { title, ...additionalProps, @@ -158,6 +162,7 @@ function Cell( [`${cellPrefixCls}-fix-right`]: isFixRight, [`${cellPrefixCls}-fix-right-first`]: firstFixRight, [`${cellPrefixCls}-ellipsis`]: ellipsis, + [`${cellPrefixCls}-with-append`]: appendNode, }, additionalProps.className, ), diff --git a/tests/__snapshots__/ExpandRow.spec.js.snap b/tests/__snapshots__/ExpandRow.spec.js.snap index 6a2dc82bc..caf066c4c 100644 --- a/tests/__snapshots__/ExpandRow.spec.js.snap +++ b/tests/__snapshots__/ExpandRow.spec.js.snap @@ -33,7 +33,7 @@ exports[`Table.Expand childrenColumnName 1`] = ` class="rc-table-row rc-table-row-level-0" >