From 5b6412a3980f524c14844e337b404bc328cd3116 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Thu, 9 Apr 2026 20:07:16 +0800 Subject: [PATCH] fix(menu): use toggleAllSelection/clearSelection for proper table selection sync - selectAll: use tableRef.toggleAllSelection() to select ALL table rows, then manually sync selectedRows.value since the event may not fire reliably - selectNone: use tableRef.clearSelection() (fires no event) + manually reset selectedRows.value = [] Co-Authored-By: Claude Opus 4.6 --- .../system/menu/components/MenuButtonCom/crud.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/views/system/menu/components/MenuButtonCom/crud.tsx b/web/src/views/system/menu/components/MenuButtonCom/crud.tsx index 65635de..9be9669 100644 --- a/web/src/views/system/menu/components/MenuButtonCom/crud.tsx +++ b/web/src/views/system/menu/components/MenuButtonCom/crud.tsx @@ -127,9 +127,10 @@ export const createCrudOptions = function ({crudExpose, context}: CreateCrudOpti const tableRef = crudExpose.getBaseTableRef(); const tableData = crudExpose.getTableData(); nextTick(() => { - XEUtils.arrayEach(tableData, (row: any) => { - tableRef.toggleRowSelection(row, true); - }); + // toggleAllSelection selects all rows regardless of current state + tableRef.toggleAllSelection(); + // Manually sync selectedRows since toggleAllSelection may not fire onSelectionChange reliably + selectedRows.value = [...tableData]; }); }, }, @@ -139,10 +140,9 @@ export const createCrudOptions = function ({crudExpose, context}: CreateCrudOpti disabled: () => selectedRows.value.length === 0, click: () => { const tableRef = crudExpose.getBaseTableRef(); - const tableData = crudExpose.getTableData(); - XEUtils.arrayEach(tableData, (row: any) => { - tableRef.toggleRowSelection(row, false); - }); + // clearSelection deselects all rows without firing events + tableRef.clearSelection(); + // Manually reset selectedRows (no event will fire from clearSelection) selectedRows.value = []; }, },