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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(editor): fix the issue where the SheetValueChanged event would be triggered if the cell value remained unchanged when exiting the editing state (#5913)
wpxp12345604660fd7015d
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.tsindex b0a5969471..155e69382f 100644--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts@@ -627,7 +627,7 @@ export class EditingRenderController extends Disposable {}const finalCell = this._sheetInterceptorService.onWriteCell(workbook, worksheet, row, column, cellData) as ICellData;- if (finalCell === worksheet.getCellRaw(row, column)) {+ if (Tools.diffValue(cleanCellDataObject(finalCell), cleanCellDataObject(worksheet.getCellRaw(row, column)))) {return true;}@@ -984,3 +984,15 @@ function emptyBody(body: IDocumentBody, removeStyle = false) {body.customBlocks = undefined;}}++function cleanCellDataObject(cellData: Nullable<ICellData>): Nullable<ICellData> {+ if (!cellData) return cellData;+ return Object.fromEntries(+ Object.entries(cellData).filter(([_, value]) => {+ if (value === undefined || value === null) return false;+ if (Array.isArray(value) && value.length === 0) return false;+ if (typeof value === 'object' && Object.keys(value).length === 0) return false;+ return true;+ })+ );+}