From 5e9eced617d3bd8d2301a59b84e86883a2ffd998 Mon Sep 17 00:00:00 2001 From: Joris Pannekeet Date: Wed, 4 Oct 2023 10:41:30 +0200 Subject: [PATCH 1/2] feat: fix checkbox for state values --- src/components/checkboxinput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/checkboxinput.js b/src/components/checkboxinput.js index 3bbb917e2..857abc4c7 100644 --- a/src/components/checkboxinput.js +++ b/src/components/checkboxinput.js @@ -21,6 +21,9 @@ const isDev = env === 'dev'; function boolify(textValue) { + if (typeof textValue === 'boolean') { + return textValue; + } return ['on', 'true', 'yes'].includes(textValue.trim().toLowerCase()); } @@ -30,7 +33,8 @@ const parsedLabel = useText(label); const labelText = parsedLabel; const resolvedValue = useText(value); - const [checked, setChecked] = usePageState(boolify(resolvedValue)); + const [isChecked, setChecked] = usePageState(resolvedValue); + const checked = boolify(isChecked); const dataComponentAttributeValue = useText(dataComponentAttribute); const helperTextResolved = useText(helperText); const validationValueMissingText = useText(validationValueMissing); From 25b3a8d9cbe1831ab29c9e729449fcad2aeabc29 Mon Sep 17 00:00:00 2001 From: Joris Pannekeet Date: Wed, 4 Oct 2023 10:44:25 +0200 Subject: [PATCH 2/2] fix: existing var --- src/components/checkboxinput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/checkboxinput.js b/src/components/checkboxinput.js index 857abc4c7..2342a0c5b 100644 --- a/src/components/checkboxinput.js +++ b/src/components/checkboxinput.js @@ -33,8 +33,8 @@ const parsedLabel = useText(label); const labelText = parsedLabel; const resolvedValue = useText(value); - const [isChecked, setChecked] = usePageState(resolvedValue); - const checked = boolify(isChecked); + const [checkedState, setChecked] = usePageState(resolvedValue); + const checked = boolify(checkedState); const dataComponentAttributeValue = useText(dataComponentAttribute); const helperTextResolved = useText(helperText); const validationValueMissingText = useText(validationValueMissing);