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] ?? "";