FieldOverride: Fixed number override so that it return undefined for null/undefined values and not NaN (#23344)

* FieldOverride: Fixed number override so that it return undefined for null/undefined values and not NaN

* Made process function be able to return undefined an null
This commit is contained in:
Torkel Ödegaard 2020-04-05 06:52:33 +02:00 committed by GitHub
parent dea91c1fd6
commit 3fae28be52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -17,11 +17,11 @@ export const numberOverrideProcessor = (
context: FieldOverrideContext,
settings?: NumberFieldConfigSettings
) => {
const v = parseFloat(`${value}`);
if (settings && settings.max && v > settings.max) {
// ????
if (value === undefined || value === null) {
return undefined;
}
return v;
return parseFloat(value);
};
export interface DataLinksFieldConfigSettings {}

View File

@ -69,7 +69,7 @@ export interface FieldPropertyEditorItem<TOptions = any, TValue = any, TSettings
override: ComponentType<FieldOverrideEditorProps<TValue, TSettings>>;
// Convert the override value to a well typed value
process: (value: any, context: FieldOverrideContext, settings?: TSettings) => TValue;
process: (value: any, context: FieldOverrideContext, settings?: TSettings) => TValue | undefined | null;
// Checks if field should be processed
shouldApply: (field: Field) => boolean;