Skip to content

Commit

Permalink
fix(table): title ellipsis (#1777)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Jan 7, 2022
1 parent 2b3b048 commit f779034
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/table/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { UpFilled, DownFilled, FilterOutlined, QuestionCircleOutlined } from '@gio-design/icons';
import { isEmpty, isUndefined } from 'lodash';
import { isEmpty, isString, isUndefined } from 'lodash';
import Button from '../button';
import Tooltip from '../tooltip';
import FilterPopover from './FilterPopover';
Expand Down Expand Up @@ -98,7 +98,12 @@ const Title = <RecordType,>(props: TitleProps<RecordType>): React.ReactElement =

return (
<div className={cls}>
{column.title}
<span
className={classNames(`${prefixCls}-column-title-text`, `${prefixCls}-column-title-text-ellipsis`)}
title={isString(column.title) ? column.title : undefined}
>
{column.title}
</span>
{renderInfo()}
{renderSorter()}
{renderFilter()}
Expand Down
16 changes: 13 additions & 3 deletions src/table/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,20 @@
}
}

.ellipsis() {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

&-cell {
box-sizing: border-box;
&-scrollbar {
position: relative;
padding: 0 !important;
}
&-ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
.ellipsis();
}
&-fix-left,
&-fix-right {
Expand Down Expand Up @@ -154,6 +158,7 @@
&-column-title {
display: flex;
align-items: center;
width: 100%;
min-height: 22px;
&-info {
display: inline-flex;
Expand All @@ -166,6 +171,11 @@
vertical-align: 0;
}
}
&-text {
&-ellipsis {
.ellipsis();
}
}
}

&-column-title-align-left {
Expand Down

1 comment on commit f779034

@vercel
Copy link

@vercel vercel bot commented on f779034 Jan 7, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.