Commit 3fae28be by Torkel Ödegaard Committed by GitHub

FieldOverride: Fixed number override so that it return undefined for…

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
parent dea91c1f
......@@ -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 {}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment