From 4e4f5324ae1f27bc610b8aa3e106da70b8e92ba5 Mon Sep 17 00:00:00 2001 From: danloa Date: Thu, 17 Feb 2022 10:06:20 -0400 Subject: [PATCH 1/3] Set variable to empty string if default expression returns undefined --- src/mixins/ScreenBase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/ScreenBase.js b/src/mixins/ScreenBase.js index be5502636..6f5107e42 100644 --- a/src/mixins/ScreenBase.js +++ b/src/mixins/ScreenBase.js @@ -93,7 +93,7 @@ export default { }, tryFormField(variableName, callback, defaultValue = null) { try { - return callback(); + return callback() || ""; } catch (e) { set(this.$v, `${variableName}.$invalid`, true); set(this.$v, `${variableName}.invalid_default_value`, false); From cf6cb22c9d569dbf9a1166360053fa5bbfac69ba Mon Sep 17 00:00:00 2001 From: danloa Date: Thu, 17 Feb 2022 11:11:06 -0400 Subject: [PATCH 2/3] Use single quotes --- src/mixins/ScreenBase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/ScreenBase.js b/src/mixins/ScreenBase.js index 6f5107e42..fa71ce476 100644 --- a/src/mixins/ScreenBase.js +++ b/src/mixins/ScreenBase.js @@ -93,7 +93,7 @@ export default { }, tryFormField(variableName, callback, defaultValue = null) { try { - return callback() || ""; + return callback() || ''; } catch (e) { set(this.$v, `${variableName}.$invalid`, true); set(this.$v, `${variableName}.invalid_default_value`, false); From 7fd2c0f428b6576ff4f2563236df76b226242cf8 Mon Sep 17 00:00:00 2001 From: danloa Date: Thu, 17 Feb 2022 11:19:43 -0400 Subject: [PATCH 3/3] Verify if it is undefined --- src/mixins/ScreenBase.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mixins/ScreenBase.js b/src/mixins/ScreenBase.js index fa71ce476..dca6a885d 100644 --- a/src/mixins/ScreenBase.js +++ b/src/mixins/ScreenBase.js @@ -93,7 +93,8 @@ export default { }, tryFormField(variableName, callback, defaultValue = null) { try { - return callback() || ''; + let result = callback(); + return (result === undefined) ? null : result; } catch (e) { set(this.$v, `${variableName}.$invalid`, true); set(this.$v, `${variableName}.invalid_default_value`, false);