From 6e964f247c547e3dfb5cf95655750013ca7bde96 Mon Sep 17 00:00:00 2001 From: ifirmawan Date: Sun, 21 Jan 2024 17:24:08 +0700 Subject: [PATCH 1/2] [#1026] Fix TypeAutofield not showing zero --- app/src/form/fields/TypeAutofield.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/form/fields/TypeAutofield.js b/app/src/form/fields/TypeAutofield.js index 6cbdf1376..e370445fd 100644 --- a/app/src/form/fields/TypeAutofield.js +++ b/app/src/form/fields/TypeAutofield.js @@ -156,8 +156,8 @@ const TypeAutofield = ({ onChange, keyform, id, name, tooltip, fn, displayOnly } if (fnColor?.[_automateValue]) { setFieldColor(fnColor[_automateValue]); } - setValue(_automateValue); - if (!displayOnly && _automateValue) { + if (!displayOnly && (_automateValue || _automateValue === 0)) { + setValue(_automateValue); FormState.update((s) => { s.currentValues[id] = _automateValue; }); @@ -183,7 +183,7 @@ const TypeAutofield = ({ onChange, keyform, id, name, tooltip, fn, displayOnly } ...styles.autoFieldContainer, backgroundColor: fieldColor || styles.autoFieldContainer.backgroundColor, }} - value={value ? (value === NaN ? null : value.toString()) : null} + value={(value || value === 0) && value !== NaN ? value.toString() : null} testID="type-autofield" multiline={true} numberOfLines={2} From 4157d4d374d349244da0b468c237bc5da54c49b5 Mon Sep 17 00:00:00 2001 From: ifirmawan Date: Sun, 21 Jan 2024 17:31:41 +0700 Subject: [PATCH 2/2] [#1026] Replace toString with String cast --- app/src/form/fields/TypeAutofield.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/form/fields/TypeAutofield.js b/app/src/form/fields/TypeAutofield.js index e370445fd..a499995d1 100644 --- a/app/src/form/fields/TypeAutofield.js +++ b/app/src/form/fields/TypeAutofield.js @@ -183,7 +183,7 @@ const TypeAutofield = ({ onChange, keyform, id, name, tooltip, fn, displayOnly } ...styles.autoFieldContainer, backgroundColor: fieldColor || styles.autoFieldContainer.backgroundColor, }} - value={(value || value === 0) && value !== NaN ? value.toString() : null} + value={(value || value === 0) && value !== NaN ? String(value) : null} testID="type-autofield" multiline={true} numberOfLines={2}