Browse Source

fix: RowSelection fixed should work (#20735)

pull/20737/head
二货机器人 5 years ago
committed by GitHub
parent
commit
4068f3d190
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      components/table/__tests__/__snapshots__/Table.rowSelection.test.js.snap
  2. 5
      components/table/hooks/useSelection.tsx

17
components/table/__tests__/__snapshots__/Table.rowSelection.test.js.snap

@ -11,7 +11,7 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-spin-container"
>
<div
class="ant-table"
class="ant-table ant-table-has-fix-left"
>
<div
class="ant-table-container"
@ -31,7 +31,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
<thead>
<tr>
<th
class="ant-table-cell ant-table-selection-column"
class="ant-table-cell ant-table-selection-column ant-table-cell-fix-left ant-table-cell-fix-left-last"
style="position:sticky;left:0"
>
<div
class="ant-table-selection"
@ -67,7 +68,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-table-row ant-table-row-level-0"
>
<td
class="ant-table-cell ant-table-selection-column"
class="ant-table-cell ant-table-selection-column ant-table-cell-fix-left ant-table-cell-fix-left-last"
style="position:sticky;left:0"
>
<label
class="ant-checkbox-wrapper"
@ -95,7 +97,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-table-row ant-table-row-level-0"
>
<td
class="ant-table-cell ant-table-selection-column"
class="ant-table-cell ant-table-selection-column ant-table-cell-fix-left ant-table-cell-fix-left-last"
style="position:sticky;left:0"
>
<label
class="ant-checkbox-wrapper"
@ -123,7 +126,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-table-row ant-table-row-level-0"
>
<td
class="ant-table-cell ant-table-selection-column"
class="ant-table-cell ant-table-selection-column ant-table-cell-fix-left ant-table-cell-fix-left-last"
style="position:sticky;left:0"
>
<label
class="ant-checkbox-wrapper"
@ -151,7 +155,8 @@ exports[`Table.rowSelection fix selection column on the left 1`] = `
class="ant-table-row ant-table-row-level-0"
>
<td
class="ant-table-cell ant-table-selection-column"
class="ant-table-cell ant-table-selection-column ant-table-cell-fix-left ant-table-cell-fix-left-last"
style="position:sticky;left:0"
>
<label
class="ant-checkbox-wrapper"

5
components/table/hooks/useSelection.tsx

@ -75,6 +75,7 @@ export default function useSelection<RecordType>(
columnWidth: selectionColWidth = 60,
type: selectionType,
selections,
fixed,
} = rowSelection || {};
const { locale = defaultLocale } = React.useContext(ConfigContext);
@ -416,11 +417,11 @@ export default function useSelection<RecordType>(
const [expandColumn, ...restColumns] = columns;
return [
expandColumn,
{ ...selectionColumn, fixed: getFixedType(restColumns[0]) },
{ ...selectionColumn, fixed: fixed || getFixedType(restColumns[0]) },
...restColumns,
];
}
return [{ ...selectionColumn, fixed: getFixedType(columns[0]) }, ...columns];
return [{ ...selectionColumn, fixed: fixed || getFixedType(columns[0]) }, ...columns];
},
[
getRowKey,

Loading…
Cancel
Save