fix: 修复table中combineNum不生效 (#5003)

This commit is contained in:
meerkat 2022-07-28 19:03:49 +08:00 committed by GitHub
parent ee90a557a4
commit 2635eb9114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 116 additions and 29 deletions

View File

@ -920,8 +920,7 @@ export const TableStore = iRendererStore
: 0);
const keys: Array<string> = [];
const len = columns.length;
for (let i = 0; i < len; i++) {
for (let i = 0; i < maxCount; i++) {
const column = columns[i];
// maxCount 可能比实际配置的 columns 还有多。

View File

@ -323,8 +323,7 @@ test('Renderer:table combineNum', () => {
{
type: 'table',
source: '$rows',
className: 'm-b-none',
combineNum: 3,
combineNum: 1,
columnsTogglable: false,
columns: [
{

View File

@ -2784,7 +2784,7 @@ exports[`Renderer:table combineNum 1`] = `
class="cxd-Service"
>
<div
class="cxd-Table m-b-none"
class="cxd-Table"
>
<div
class="cxd-Table-contentWrap"
@ -3005,7 +3005,6 @@ exports[`Renderer:table combineNum 1`] = `
>
<td
class=""
rowspan="3"
>
<span
class="cxd-PlainField"
@ -3048,7 +3047,15 @@ exports[`Renderer:table combineNum 1`] = `
>
<td
class=""
rowspan="2"
>
<span
class="cxd-PlainField"
>
AOL browser (AOL desktop)
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
@ -3080,6 +3087,24 @@ exports[`Renderer:table combineNum 1`] = `
data-id="5"
data-index="4"
>
<td
class=""
>
<span
class="cxd-PlainField"
>
AOL browser (AOL desktop)
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
Win 98
</span>
</td>
<td
class=""
>
@ -3116,7 +3141,6 @@ exports[`Renderer:table combineNum 1`] = `
</td>
<td
class=""
rowspan="2"
>
<span
class="cxd-PlainField"
@ -3126,7 +3150,6 @@ exports[`Renderer:table combineNum 1`] = `
</td>
<td
class=""
rowspan="2"
>
<span
class="cxd-PlainField"
@ -3158,6 +3181,24 @@ exports[`Renderer:table combineNum 1`] = `
data-id="7"
data-index="6"
>
<td
class=""
>
<span
class="cxd-PlainField"
>
Firefox 1.0
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
Win 98+ / OSX.2+
</span>
</td>
<td
class=""
>
@ -3184,7 +3225,6 @@ exports[`Renderer:table combineNum 1`] = `
>
<td
class=""
rowspan="3"
>
<span
class="cxd-PlainField"
@ -3194,7 +3234,6 @@ exports[`Renderer:table combineNum 1`] = `
</td>
<td
class=""
rowspan="3"
>
<span
class="cxd-PlainField"
@ -3204,7 +3243,6 @@ exports[`Renderer:table combineNum 1`] = `
</td>
<td
class=""
rowspan="3"
>
<span
class="cxd-PlainField"
@ -3227,6 +3265,33 @@ exports[`Renderer:table combineNum 1`] = `
data-id="9"
data-index="8"
>
<td
class=""
>
<span
class="cxd-PlainField"
>
Firefox 2.0
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
Win 98+ / OSX.2+
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
5
</span>
</td>
<td
class=""
>
@ -3242,6 +3307,33 @@ exports[`Renderer:table combineNum 1`] = `
data-id="10"
data-index="9"
>
<td
class=""
>
<span
class="cxd-PlainField"
>
Firefox 2.0
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
Win 98+ / OSX.2+
</span>
</td>
<td
class=""
>
<span
class="cxd-PlainField"
>
5
</span>
</td>
<td
class=""
>

View File

@ -226,7 +226,7 @@ export class TableContent extends React.Component<TableContentProps> {
dispatchEvent,
onEvent
}}
></TableBody>
/>
)}
</table>
</div>

View File

@ -2198,11 +2198,9 @@ export default class Table extends React.Component<TableProps, object> {
const columnsGroup = store.columnGroup;
return (
<table
className={cx(
'Table-table',
store.combineNum > 0 ? 'Table-table--withCombine' : '',
tableClassName
)}
className={cx('Table-table', tableClassName, {
'Table-table--withCombine': store.combineNum > 0
})}
>
<thead>
{columnsGroup.length ? (
@ -2249,10 +2247,9 @@ export default class Table extends React.Component<TableProps, object> {
</tbody>
) : (
<TableBody
tableClassName={cx(
store.combineNum > 0 ? 'Table-table--withCombine' : '',
tableClassName
)}
tableClassName={cx(tableClassName, {
'Table-table--withCombine': store.combineNum > 0
})}
itemAction={itemAction}
classnames={cx}
render={render}
@ -2702,8 +2699,10 @@ export default class Table extends React.Component<TableProps, object> {
<>
<TableContent
tableClassName={cx(
store.combineNum > 0 ? 'Table-table--withCombine' : '',
{'Table-table--checkOnItemClick': checkOnItemClick},
{
'Table-table--checkOnItemClick': checkOnItemClick,
'Table-table--withCombine': store.combineNum > 0
},
tableClassName
)}
className={tableContentClassName}
@ -2795,11 +2794,9 @@ export default class Table extends React.Component<TableProps, object> {
const heading = this.renderHeading();
const header = this.renderHeader();
const footer = this.renderFooter();
const tableClassName = cx(
'Table-table',
store.combineNum > 0 ? 'Table-table--withCombine' : '',
this.props.tableClassName
);
const tableClassName = cx('Table-table', this.props.tableClassName, {
'Table-table--withCombine': store.combineNum > 0
});
return (
<div