From 364715eba3ce4017d7e0e276d4411ffbc62c2966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Mon, 25 Jul 2022 11:49:35 +0200 Subject: [PATCH] (core) FormulaEditor was updating formula when nothing has changed Summary: FormulaEditor on sidepanel was sending update action when formula wasn't updated by the user. Test Plan: Existing tests Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3545 --- app/client/widgets/FormulaEditor.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/client/widgets/FormulaEditor.ts b/app/client/widgets/FormulaEditor.ts index 83fa5b28..3beb3987 100644 --- a/app/client/widgets/FormulaEditor.ts +++ b/app/client/widgets/FormulaEditor.ts @@ -293,12 +293,17 @@ export function openFormulaEditor(options: { // AsyncOnce ensures it's called once even if triggered multiple times. const saveEdit = asyncOnce(async () => { const formula = editor.getCellValue(); - if (options.onSave) { - await options.onSave(column, formula as string); - } else if (formula !== column.formula.peek()) { - await column.updateColValues({formula}); + if (formula !== column.formula.peek()) { + if (options.onSave) { + await options.onSave(column, formula as string); + } else { + await column.updateColValues({formula}); + } + holder.dispose(); + } else { + holder.dispose(); + options.onCancel?.(); } - holder.dispose(); }); // These are the commands for while the editor is active.