fix(grid): stop stealing focus after cell edit commit on blur

This commit is contained in:
zipg authored and GitHub committed 2026-09-21 11:37:38 +08:00
1 parent e364e4a70f
commit 566bfc3039
7 files changed
+74 -4

No files matched your search

+12 -3
View File
@@ -327,7 +327,7 @@ import { useConnectionStore } from "@/stores/connectionStore";
import { useQueryStore } from "@/stores/queryStore";
import { useSettingsStore } from "@/stores/settingsStore";
import { databaseSortSupportedForDatabase, simpleDataGridOrderByMatchesSort, simpleDataGridOrderByReferencesMissingColumn, type DataGridSortDirection, type DataGridSortMode } from "@/lib/dataGrid/dataGridSort";
import { resolveGridFocusRestoreTarget } from "@/lib/dataGrid/dataGridFocusRestore";
import { resolveGridFocusRestoreTarget, shouldRestoreDataGridFocusAfterEditCommit } from "@/lib/dataGrid/dataGridFocusRestore";
import { buildOrderedGridRows, type GridInsertRowPosition, type GridNewRowPlacement } from "@/lib/dataGrid/gridNewRowPlacement";
import {
DATA_GRID_CONDITION_TOOLBAR_MIN_WIDTH,
@@ -8936,7 +8936,14 @@ function currentIoTDBTimestampEditValue(): CellValue | undefined {
function commitGridEdit(value?: CellValue) {
if (value === undefined) value = currentIoTDBTimestampEditValue();
if (commitInlineBulkEdit(value)) return;
void commitEditAndMaybeAutoSave(value === undefined ? undefined : { explicitValue: value }).finally(() => nextTick(() => gridRef.value?.focus({ preventScroll: true })));
void commitEditAndMaybeAutoSave(value === undefined ? undefined : { explicitValue: value }).finally(() =>
nextTick(() => {
// A click outside the grid (SQL editor, WHERE bar, toolbar) already moved focus on
// purpose. Only pull it back when the grid still owns it, otherwise the element the
// user just clicked loses the caret and swallows the following keystroke (#9383).
if (shouldRestoreDataGridFocusAfterEditCommit(gridRef.value, document.activeElement)) gridRef.value?.focus({ preventScroll: true });
}),
);
}
function commitInlineBulkEdit(value?: CellValue): boolean {
@@ -8945,7 +8952,9 @@ function commitInlineBulkEdit(value?: CellValue): boolean {
const nextValue = value === undefined ? editValue.value : value === null ? null : String(value);
cancelEdit();
fillSelectionWithValue(nextValue, { emptyStringAsNull: true });
nextTick(() => gridRef.value?.focus({ preventScroll: true }));
nextTick(() => {
if (shouldRestoreDataGridFocusAfterEditCommit(gridRef.value, document.activeElement)) gridRef.value?.focus({ preventScroll: true });
});
return true;
}