Commit 5ad5c8cdc7df4454fb16df115180b477b4e44fe3
Committed by
GitHub
1 parent
27cb958c
fix: 类似 /comp/table/formTable页面 rowSelection.selectedRowKeys 数据双向绑定时 clickToRowS…
…elect RowClick 触发失效 (#2893)
Showing
1 changed file
with
3 additions
and
2 deletions
src/components/Table/src/hooks/useCustomRow.ts
@@ -42,7 +42,7 @@ export function useCustomRow( | @@ -42,7 +42,7 @@ export function useCustomRow( | ||
42 | if (!rowSelection || !clickToRowSelect) return; | 42 | if (!rowSelection || !clickToRowSelect) return; |
43 | const keys = getSelectRowKeys() || []; | 43 | const keys = getSelectRowKeys() || []; |
44 | const key = getKey(record, rowKey, unref(getAutoCreateKey)); | 44 | const key = getKey(record, rowKey, unref(getAutoCreateKey)); |
45 | - if (!key) return; | 45 | + if (key === null) return; |
46 | 46 | ||
47 | const isCheckbox = rowSelection.type === 'checkbox'; | 47 | const isCheckbox = rowSelection.type === 'checkbox'; |
48 | if (isCheckbox) { | 48 | if (isCheckbox) { |
@@ -55,7 +55,8 @@ export function useCustomRow( | @@ -55,7 +55,8 @@ export function useCustomRow( | ||
55 | const checkBox = tr.querySelector('input[type=checkbox]'); | 55 | const checkBox = tr.querySelector('input[type=checkbox]'); |
56 | if (!checkBox || checkBox.hasAttribute('disabled')) return; | 56 | if (!checkBox || checkBox.hasAttribute('disabled')) return; |
57 | if (!keys.includes(key)) { | 57 | if (!keys.includes(key)) { |
58 | - setSelectedRowKeys([...keys, key]); | 58 | + keys.push(key); |
59 | + setSelectedRowKeys(keys); | ||
59 | return; | 60 | return; |
60 | } | 61 | } |
61 | const keyIndex = keys.findIndex((item) => item === key); | 62 | const keyIndex = keys.findIndex((item) => item === key); |