Skip to content

Commit

Permalink
feat(Table): add wordWrap option to prevent text cut (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov authored Aug 22, 2023
1 parent 4ced5a0 commit 52d6efb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/Table/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
}

&__cell {
@include mixins.overflow-ellipsis();

box-sizing: content-box;
padding: 11px 10px;
border-bottom: 1px solid var(--g-color-line-generic);
Expand All @@ -68,6 +66,10 @@
padding-right: 0;
}

&:not(&_word-wrap) {
@include mixins.overflow-ellipsis();
}

&_align_center {
text-align: center;
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface TableProps<I> extends QAProps {
columns: TableColumnConfig<I>[];
/** Vertical alignment of contents */
verticalAlign?: 'top' | 'middle';
/** Break long text to lines instead of cutting with hellip */
wordWrap?: boolean;
/**
* Horizontal sticky scroll.
* Note: table cannot be with fixed height and with sticky scroll at the same time.
Expand Down Expand Up @@ -333,7 +335,7 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
}

private renderHead() {
const {columns, edgePadding} = this.props;
const {columns, edgePadding, wordWrap} = this.props;
const {columnsStyles} = this.state;

return (
Expand All @@ -355,6 +357,7 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
primary,
sticky,
['edge-padding']: edgePadding,
['word-wrap']: wordWrap,
},
className,
)}
Expand Down Expand Up @@ -398,6 +401,7 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
getRowClassNames,
verticalAlign,
edgePadding,
wordWrap,
} = this.props;
const {columnsStyles} = this.state;

Expand Down Expand Up @@ -447,6 +451,7 @@ export class Table<I extends TableDataItem = Record<string, string>> extends Rea
primary,
sticky,
['edge-padding']: edgePadding,
['word-wrap']: wordWrap,
},
className,
)}
Expand Down

0 comments on commit 52d6efb

Please sign in to comment.