From f42430b9852c96caea75080171d399c03e210dc2 Mon Sep 17 00:00:00 2001 From: gathanase Date: Mon, 3 Jul 2023 20:42:39 +0200 Subject: [PATCH] Fix custom pair fields examples (#8663) --- examples/custom-field/3-pair-field-json/index.ts | 1 + examples/custom-field/3-pair-field-nested/index.ts | 1 + examples/custom-field/3-pair-field/index.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/custom-field/3-pair-field-json/index.ts b/examples/custom-field/3-pair-field-json/index.ts index 5d39d824049..999b857b2fd 100644 --- a/examples/custom-field/3-pair-field-json/index.ts +++ b/examples/custom-field/3-pair-field-json/index.ts @@ -44,6 +44,7 @@ export function pair( config: PairFieldConfig = {} ): FieldTypeFunc { function resolveInput(value: PairInput | null | undefined) { + if (value === undefined) return undefined; const { left = null, right = null } = value ?? {}; return JSON.stringify({ left, right }); } diff --git a/examples/custom-field/3-pair-field-nested/index.ts b/examples/custom-field/3-pair-field-nested/index.ts index 3a30e635237..d1599e0feee 100644 --- a/examples/custom-field/3-pair-field-nested/index.ts +++ b/examples/custom-field/3-pair-field-nested/index.ts @@ -44,6 +44,7 @@ export function pair( config: PairFieldConfig = {} ): FieldTypeFunc { function resolveInput(value: PairInput | null | undefined) { + if (value === undefined) return undefined; const { left = null, right = null } = value ?? {}; return { left, right }; } diff --git a/examples/custom-field/3-pair-field/index.ts b/examples/custom-field/3-pair-field/index.ts index 4e105ec7184..8eb8d463492 100644 --- a/examples/custom-field/3-pair-field/index.ts +++ b/examples/custom-field/3-pair-field/index.ts @@ -26,7 +26,7 @@ export function pair( config: PairFieldConfig = {} ): FieldTypeFunc { function resolveInput(value: PairInput | null | undefined) { - if (!value) return { left: value, right: value }; + if (value === undefined) return undefined; const [left = '', right = ''] = value.split(' ', 2); return { left,