From 5a876976d53ebb0fb24e4b6c5ed45347fbb24c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Tue, 11 Jan 2022 14:33:07 +0100 Subject: [PATCH] (core) Preventing empty string update on any column. Summary: When editor is opened on any column and closed without entering any value, the column is converted to a text column. Test Plan: browser tests Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3211 --- app/common/ValueParser.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/common/ValueParser.ts b/app/common/ValueParser.ts index 356d458f..ebf9e72b 100644 --- a/app/common/ValueParser.ts +++ b/app/common/ValueParser.ts @@ -32,6 +32,17 @@ export class ValueParser { } +/** + * Same as basic Value parser, but will return null if a value is an empty string. + */ +class NullIfEmptyParser extends ValueParser { + public cleanParse(value: string): any { + if (value === "") { + return null; + } + return super.cleanParse(value); + } +} export class NumericParser extends ValueParser { private _parse: NumberParse; @@ -206,6 +217,7 @@ export class ReferenceListParser extends ReferenceParser { } export const valueParserClasses: { [type: string]: typeof ValueParser } = { + Any: NullIfEmptyParser, Numeric: NumericParser, Int: NumericParser, Date: DateParser,