From 6844f69c2068807eb0bd876d30f7b7de447c841a Mon Sep 17 00:00:00 2001 From: WYH <18639003229@163.com> Date: Wed, 16 Nov 2022 17:19:27 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Ddemo=E4=B8=ADfor?= =?UTF-8?q?mTable=E5=87=A0=E4=B8=AA=E7=A9=BA=E6=8C=87=E9=92=88=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=92=8CselectedRowKeys=E4=B8=A2=E5=A4=B1=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=BC=8F=E7=9A=84=E9=97=AE=E9=A2=98=20(#2386)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 王一骅 --- src/components/Table/src/hooks/useCustomRow.ts | 2 +- src/components/Table/src/hooks/useRowSelection.ts | 4 ++-- src/views/demo/table/FormTable.vue | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/Table/src/hooks/useCustomRow.ts b/src/components/Table/src/hooks/useCustomRow.ts index 56187208e83..1a5aac85891 100644 --- a/src/components/Table/src/hooks/useCustomRow.ts +++ b/src/components/Table/src/hooks/useCustomRow.ts @@ -40,7 +40,7 @@ export function useCustomRow( function handleClick() { const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef); if (!rowSelection || !clickToRowSelect) return; - const keys = getSelectRowKeys(); + const keys = getSelectRowKeys() || []; const key = getKey(record, rowKey, unref(getAutoCreateKey)); if (!key) return; diff --git a/src/components/Table/src/hooks/useRowSelection.ts b/src/components/Table/src/hooks/useRowSelection.ts index 3439a223bba..ed19b072a67 100644 --- a/src/components/Table/src/hooks/useRowSelection.ts +++ b/src/components/Table/src/hooks/useRowSelection.ts @@ -66,13 +66,13 @@ export function useRowSelection( selectedRowKeysRef.value = rowKeys; const allSelectedRows = findNodeAll( toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))), - (item) => rowKeys.includes(item[unref(getRowKey) as string]), + (item) => rowKeys?.includes(item[unref(getRowKey) as string]), { children: propsRef.value.childrenColumnName ?? 'children', }, ); const trueSelectedRows: any[] = []; - rowKeys.forEach((key: string) => { + rowKeys?.forEach((key: string) => { const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key); found && trueSelectedRows.push(found); }); diff --git a/src/views/demo/table/FormTable.vue b/src/views/demo/table/FormTable.vue index 23300aa7c92..fc565edfe12 100644 --- a/src/views/demo/table/FormTable.vue +++ b/src/views/demo/table/FormTable.vue @@ -1,8 +1,5 @@