Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): #1039 can not type directly into a cell after dragging a selection (#1090)

Gpound.liu22c71b90efaf
diff --git a/packages/sheets/src/commands/commands/move-range.command.ts b/packages/sheets/src/commands/commands/move-range.command.ts
index 32df376a09..b3846cbc26 100644
--- a/packages/sheets/src/commands/commands/move-range.command.ts
+++ b/packages/sheets/src/commands/commands/move-range.command.ts
@@ -32,6 +32,7 @@ import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-
import type { IMoveRangeMutationParams } from '../mutations/move-range.mutation';
import { MoveRangeMutation } from '../mutations/move-range.mutation';
import { SetSelectionsOperation } from '../operations/selection.operation';
+import { getPrimaryForRange } from './utils/selection-utils';
export interface IMoveRangeCommandParams {
toRange: IRange;
@@ -113,7 +114,7 @@ export const MoveRangeCommand: ICommand = {
unitId,
sheetId: subUnitId,
pluginName: NORMAL_SELECTION_PLUGIN_NAME,
- selections: [{ range: params.toRange }],
+ selections: [{ range: params.toRange, primary: getPrimaryForRange(params.toRange, worksheet) }],
},
},
];
@@ -124,7 +125,7 @@ export const MoveRangeCommand: ICommand = {
unitId,
sheetId: subUnitId,
pluginName: NORMAL_SELECTION_PLUGIN_NAME,
- selections: [{ range: params.fromRange }],
+ selections: [{ range: params.fromRange, primary: getPrimaryForRange(params.fromRange, worksheet) }],
},
},
...interceptorCommands.undos,