mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-21 03:15:49 +08:00
refactor(arco/Table): remove selectedRow state and add rowSelectChange events
seletedRow is a confusing property. It actually represents the row you are currently working on. In the case of multiple selections, the selectedRow is the current row regardless of whether the current row is selected or unselected. Although arco provides `selected` to determine if the current row is selected, there is a lot of extra logic required to determine if the selectedRow has a value. And in single selection, `selectedRow` and `selectedRows` can be confusing
This commit is contained in:
parent
3f94a694e0
commit
da6521324a
@ -30,7 +30,6 @@ import { useStateValue } from '../../hooks/useStateValue';
|
||||
const TableStateSpec = Type.Object({
|
||||
clickedRow: Type.Optional(Type.Any()),
|
||||
selectedRows: Type.Array(Type.Any()),
|
||||
selectedRow: Type.Optional(Type.Any()),
|
||||
selectedRowKeys: Type.Array(Type.String()),
|
||||
filterRule: Type.Any(),
|
||||
sortRule: Type.Object({
|
||||
@ -157,7 +156,15 @@ export const Table = implementRuntimeComponent({
|
||||
},
|
||||
},
|
||||
styleSlots: ['content'],
|
||||
events: ['onRowClick', 'onSearch', 'onPageChange', 'onFilter', 'onSort', 'onChange'],
|
||||
events: [
|
||||
'onRowClick',
|
||||
'onSearch',
|
||||
'onPageChange',
|
||||
'onFilter',
|
||||
'onSort',
|
||||
'onChange',
|
||||
'rowSelectChange',
|
||||
],
|
||||
},
|
||||
})(props => {
|
||||
const {
|
||||
@ -492,21 +499,12 @@ export const Table = implementRuntimeComponent({
|
||||
checkCrossPage: checkCrossPage,
|
||||
// This option is required to achieve multi-selection across pages when customizing paging
|
||||
preserveSelectedRowKeys: useCustomPagination ? checkCrossPage : undefined,
|
||||
onSelect: (selected, record) => {
|
||||
mergeState({
|
||||
selectedRow: selected ? record : undefined,
|
||||
});
|
||||
},
|
||||
onSelectAll: () => {
|
||||
mergeState({
|
||||
selectedRow: undefined,
|
||||
});
|
||||
},
|
||||
onChange(selectedRowKeys, selectedRows) {
|
||||
mergeState({
|
||||
selectedRowKeys: selectedRowKeys as string[],
|
||||
selectedRows,
|
||||
});
|
||||
callbackMap?.rowSelectChange?.();
|
||||
},
|
||||
}}
|
||||
onRow={
|
||||
|
Loading…
Reference in New Issue
Block a user