From bb839b228e8ad38714b4e71d938b451623bcfcaa Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Mon, 30 Oct 2023 15:38:00 +0100 Subject: [PATCH] fix(de form async validation): prevent other field validation --- src/pages/dataElements/form/fields.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/dataElements/form/fields.tsx b/src/pages/dataElements/form/fields.tsx index 5d5dd74c..3645b9a8 100644 --- a/src/pages/dataElements/form/fields.tsx +++ b/src/pages/dataElements/form/fields.tsx @@ -46,7 +46,10 @@ export function NameField() { helpText={i18n.t( 'A data element name should be concise and easy to recognize.' )} - validate={checkIsValueTaken} + // Do not pass checkIsValueTaken directly, otherwise memoization + // won't work due to additional arguments being passed + validate={(name: string) => checkIsValueTaken(name)} + validateFields={[]} /> ) } @@ -70,7 +73,10 @@ export function ShortNameField() { })} name="shortName" helpText={i18n.t('Often used in reports where space is limited')} - validate={checkIsValueTaken} + // Do not pass checkIsValueTaken directly, otherwise memoization + // won't work due to additional arguments being passed + validate={(shortName: string) => checkIsValueTaken(shortName)} + validateFields={[]} /> ) }