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(event): fix BeforeSheetEditEnd cancel (#5889)

wpxp12345656368fa2476e
diff --git a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
index f487745154..52c94e8496 100644
--- a/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
+++ b/packages/sheets-ui/src/views/formula-bar/FormulaBar.tsx
@@ -236,7 +236,7 @@ export function FormulaBar(props: IProps) {
// When clicking on the formula bar, the cell editor also needs to enter the edit state
const visibleState = editorBridgeService.isVisible();
if (visibleState.visible === false) {
- commandService.syncExecuteCommand(
+ const result = commandService.syncExecuteCommand(
SetCellEditVisibleOperation.id,
{
visible: true,
@@ -244,6 +244,11 @@ export function FormulaBar(props: IProps) {
unitId: editState!.unitId,
} as IEditorBridgeServiceVisibleParam
);
+ // cancel by event
+ if (!result) {
+ shouldSkipFocus.current = true;
+ return;
+ }
// undoRedoService.clearUndoRedo(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
}