Skip to content

Commit

Permalink
🆙 upgrade rc-table
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Sep 3, 2019
1 parent 806e7a4 commit a1cde52
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 29 deletions.
23 changes: 1 addition & 22 deletions components/table/Table.tsx
Expand Up @@ -867,26 +867,6 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
return getColumnKey(sortColumn) === getColumnKey(column);
}

isTableLayoutFixed() {
const { tableLayout, columns = [], rowSelection, useFixedHeader, scroll = {} } = this.props;
if (tableLayout === 'fixed') {
return true;
}
// if one column fixed, use fixed table layout to fix align issue
if (columns.some(({ fixed }) => !!fixed)) {
return true;
}
// if selection column fixed, use fixed table layout to fix align issue
if (rowSelection && rowSelection.fixed) {
return true;
}
// if header fixed, use fixed table layout to fix align issue
if (useFixedHeader || scroll.y) {
return true;
}
return false;
}

// Get pagination, filters, sorter
prepareParamsArguments(state: any): PrepareParamsArgumentsReturn<T> {
const pagination = { ...state.pagination };
Expand Down Expand Up @@ -1238,7 +1218,7 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
}) => {
const { showHeader, locale, getPopupContainer, ...restTableProps } = this.props;
// do not pass prop.style to rc-table, since already apply it to container div
const restProps = omit(restTableProps, ['style', 'tableLayout']);
const restProps = omit(restTableProps, ['style']);
const data = this.getCurrentPageData();
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;

Expand All @@ -1255,7 +1235,6 @@ export default class Table<T> extends React.Component<TableProps<T>, TableState<
[`${prefixCls}-bordered`]: this.props.bordered,
[`${prefixCls}-empty`]: !data.length,
[`${prefixCls}-without-column-header`]: !showHeader,
[`${prefixCls}-layout-fixed`]: this.isTableLayoutFixed(),
});

const columnsWithRowSelection = this.renderRowSelection({
Expand Down
8 changes: 4 additions & 4 deletions components/table/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -5000,7 +5000,7 @@ exports[`renders ./components/table/demo/fixed-columns.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-scroll-position-left"
class="ant-table ant-table-default ant-table-scroll-position-left ant-table-layout-fixed"
>
<div
class="ant-table-content"
Expand Down Expand Up @@ -5636,7 +5636,7 @@ exports[`renders ./components/table/demo/fixed-columns-header.md correctly 1`] =
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-fixed-header ant-table-scroll-position-left"
class="ant-table ant-table-default ant-table-fixed-header ant-table-scroll-position-left ant-table-layout-fixed"
>
<div
class="ant-table-content"
Expand Down Expand Up @@ -7155,7 +7155,7 @@ exports[`renders ./components/table/demo/fixed-header.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-default ant-table-fixed-header ant-table-scroll-position-left"
class="ant-table ant-table-default ant-table-fixed-header ant-table-scroll-position-left ant-table-layout-fixed"
>
<div
class="ant-table-content"
Expand Down Expand Up @@ -8364,7 +8364,7 @@ exports[`renders ./components/table/demo/grouping-columns.md correctly 1`] = `
class="ant-spin-container"
>
<div
class="ant-table ant-table-middle ant-table-bordered ant-table-fixed-header ant-table-scroll-position-left"
class="ant-table ant-table-middle ant-table-bordered ant-table-fixed-header ant-table-scroll-position-left ant-table-layout-fixed"
>
<div
class="ant-table-content"
Expand Down
2 changes: 1 addition & 1 deletion components/table/index.en-US.md
Expand Up @@ -59,7 +59,7 @@ const columns = [

| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| tableLayout | [table-layout](https://developer.mozilla.org/zh-CN/docs/Web/CSS/table-layout) attribute of table element | 'auto' \| 'fixed' | 'auto', `fixed` when header or columns are fixed` | 3.24.0 |
| tableLayout | [table-layout](https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout) attribute of table element | 'auto' \| 'fixed' | 'auto', `fixed` when header or columns are fixed` | 3.24.0 |
| bordered | Whether to show all table borders | boolean | `false` | |
| childrenColumnName | The column contains children to display | string\[] | children | 3.4.2 |
| columns | Columns of table | [ColumnProps](https://git.io/vMMXC)\[] | - | |
Expand Down
2 changes: 1 addition & 1 deletion components/table/index.zh-CN.md
Expand Up @@ -64,7 +64,7 @@ const columns = [

| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| tableLayout | 表格元素的 [table-layout](https://developer.mozilla.org/zh-CN/docs/Web/CSS/table-layout) 属性 | 'auto' \| 'fixed' | 'auto',当固定头或固定列时默认值为 `fixed` | 3.24.0 |
| tableLayout | 表格元素的 [table-layout](https://developer.mozilla.org/zh-CN/docs/Web/CSS/table-layout) 属性,设为 `fixed` 表示内容不会影响列的布局 | 'auto' \| 'fixed' | 'auto',当固定头或固定列时默认值为 `fixed` | 3.24.0 |
| bordered | 是否展示外边框和列边框 | boolean | false | |
| childrenColumnName | 指定树形结构的列名 | string\[] | children | 3.4.2 |
| columns | 表格列的配置描述,具体项见下表 | [ColumnProps](https://git.io/vMMXC)\[] | - | |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -79,7 +79,7 @@
"rc-slider": "~8.6.11",
"rc-steps": "~3.5.0",
"rc-switch": "~1.9.0",
"rc-table": "~6.7.0",
"rc-table": "~6.8.1",
"rc-tabs": "~9.6.4",
"rc-time-picker": "~3.7.1",
"rc-tooltip": "~3.7.3",
Expand Down

0 comments on commit a1cde52

Please sign in to comment.