@ -380,13 +380,13 @@ export class FieldEditor extends Disposable {
if ( ! editor ) { return false ; }
if ( ! editor ) { return false ; }
// Make sure the editor is save ready
// Make sure the editor is save ready
const saveIndex = this . _cursor . rowIndex ( ) ;
const saveIndex = this . _cursor . rowIndex ( ) ;
return await this . _gristDoc . docData . bundleActions ( null , async ( ) = > {
await editor . prepForSave ( ) ;
await editor . prepForSave ( ) ;
if ( this . isDisposed ( ) ) {
if ( this . isDisposed ( ) ) {
// We shouldn't normally get disposed here, but if we do, avoid confusing JS errors.
// We shouldn't normally get disposed here, but if we do, avoid confusing JS errors.
console . warn ( t ( "Unable to finish saving edited cell" ) ) ; // tslint:disable-line:no-console
console . warn ( t ( "Unable to finish saving edited cell" ) ) ; // tslint:disable-line:no-console
return false ;
return false ;
}
}
// Then save the value the appropriate way
// Then save the value the appropriate way
// TODO: this isFormula value doesn't actually reflect if editing the formula, since
// TODO: this isFormula value doesn't actually reflect if editing the formula, since
// editingFormula() is used for toggling column headers, and this is deferred to start of
// editingFormula() is used for toggling column headers, and this is deferred to start of
@ -400,13 +400,13 @@ export class FieldEditor extends Disposable {
const formula = String ( editor . getCellValue ( ) ? ? '' ) ;
const formula = String ( editor . getCellValue ( ) ? ? '' ) ;
// Bundle multiple changes so that we can undo them in one step.
// Bundle multiple changes so that we can undo them in one step.
if ( isFormula !== col . isFormula . peek ( ) || formula !== col . formula . peek ( ) ) {
if ( isFormula !== col . isFormula . peek ( ) || formula !== col . formula . peek ( ) ) {
waitPromise = this . _gristDoc . docData . bundleActions ( null , ( ) = > Promise . all ( [
waitPromise = Promise . all ( [
col . updateColValues ( { isFormula , formula } ) ,
col . updateColValues ( { isFormula , formula } ) ,
// If we're saving a non-empty formula, then also add an empty record to the table
// If we're saving a non-empty formula, then also add an empty record to the table
// so that the formula calculation is visible to the user.
// so that the formula calculation is visible to the user.
( ! this . _detached . get ( ) && this . _editRow . _isAddRow . peek ( ) && formula !== "" ?
( ! this . _detached . get ( ) && this . _editRow . _isAddRow . peek ( ) && formula !== "" ?
this . _editRow . updateColValues ( { } ) : undefined ) ,
this . _editRow . updateColValues ( { } ) : undefined ) ,
] ) ) ;
] ) ;
}
}
} else {
} else {
const value = editor . getCellValue ( ) ;
const value = editor . getCellValue ( ) ;
@ -433,6 +433,7 @@ export class FieldEditor extends Disposable {
this . dispose ( ) ;
this . dispose ( ) ;
await waitPromise ;
await waitPromise ;
return isFormula || ( saveIndex !== cursor . rowIndex ( ) ) ;
return isFormula || ( saveIndex !== cursor . rowIndex ( ) ) ;
} ) ;
}
}
}
}