From 4311ace96011e6ab5030e9132bd66cab602d285b Mon Sep 17 00:00:00 2001 From: zipg Date: Mon, 10 Aug 2026 10:28:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(grid):=20=E4=BF=AE=E5=A4=8D=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E7=94=9F=E6=88=90=E5=80=BC=E5=90=8E=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: zipg <4047349+zipg@users.noreply.github.com> --- apps/desktop/src/components/grid/DataGrid.vue | 5 ++++- packages/app-tests/dataGridContextMenu.test.ts | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index e55bd2658d..04d496ccfe 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -6464,7 +6464,10 @@ function applyGeneratedSelectionValue(kind: CellValueGenerationKind, startValue } finally { commitBatch(); } - if (applied) toast(t("grid.generatedValuesApplied", { count: cells.length })); + if (applied) { + toast(t("grid.generatedValuesApplied", { count: cells.length })); + void nextTick(() => window.requestAnimationFrame(() => gridRef.value?.focus({ preventScroll: true }))); + } return applied; } diff --git a/packages/app-tests/dataGridContextMenu.test.ts b/packages/app-tests/dataGridContextMenu.test.ts index c7d665fa2f..e2e95d43fe 100644 --- a/packages/app-tests/dataGridContextMenu.test.ts +++ b/packages/app-tests/dataGridContextMenu.test.ts @@ -23,6 +23,12 @@ test("set NULL applies a real null value only to editable selections", () => { assert.doesNotMatch(handler, /fillSelectionWithValue\(["'](?:NULL)?["']\)/); }); +test("generated selection values restore grid focus for keyboard shortcuts", () => { + const applyHandler = dataGridSource.match(/function applyGeneratedSelectionValue\([^]*?\n\}/)?.[0] ?? ""; + + assert.match(applyHandler, /if \(applied\)[^]*nextTick\(\(\) => window\.requestAnimationFrame\(\(\) => gridRef\.value\?\.focus\(\{ preventScroll: true \}\)\)\)/); +}); + test("column-header context menus defer copy statement generation", () => { const handler = dataGridSource.match(/function onHeaderContext\([^]*?\n\}/)?.[0] ?? "";