From 25e197a22eecec527b2b284aee0b95ccb1cd3797 Mon Sep 17 00:00:00 2001 From: tshuli Date: Fri, 17 Mar 2023 18:34:37 +0800 Subject: [PATCH 1/3] fix: trim dropdown options for logic check --- .../logic/utils/isConditionFulfilled.ts | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/frontend/src/features/logic/utils/isConditionFulfilled.ts b/frontend/src/features/logic/utils/isConditionFulfilled.ts index 1efd9ab633..a1d7842b30 100644 --- a/frontend/src/features/logic/utils/isConditionFulfilled.ts +++ b/frontend/src/features/logic/utils/isConditionFulfilled.ts @@ -64,44 +64,56 @@ export const isConditionFulfilled = ( const args = { fieldType, input } if (!isLogicableField(args)) return false + // TODO #4279: Revisit decision to trim after React rollout is complete + let currentValueTrimmed const currentValue = getCurrentFieldValue(args.input, args.fieldType) - if (currentValue === '') { + if (currentValueTrimmed === '') { return false } + if (typeof currentValue === 'string') { + currentValueTrimmed = currentValue.trim() + } else if (typeof currentValue.value === 'string') { + currentValueTrimmed = { + ...currentValue, + value: currentValue.value.trim(), + } + } else { + currentValueTrimmed = currentValue + } switch (conditionTrimmed.state) { case LogicConditionState.Lte: - return Number(currentValue) <= Number(conditionTrimmed.value) + return Number(currentValueTrimmed) <= Number(conditionTrimmed.value) case LogicConditionState.Gte: - return Number(currentValue) >= Number(conditionTrimmed.value) + return Number(currentValueTrimmed) >= Number(conditionTrimmed.value) case LogicConditionState.Either: { // currentValue must be in a value in condition.value const condValuesArray = Array.isArray(conditionTrimmed.value) ? conditionTrimmed.value.map(String) : [String(conditionTrimmed.value)] - if (isRadioFormFieldValue(currentValue, args.fieldType)) { + if (isRadioFormFieldValue(currentValueTrimmed, args.fieldType)) { if (condValuesArray.includes('Others')) { // If the condition value is 'Others', // then the condition must be satisfied if the current value is the special input value AND // if the othersInput subfield has a value. const satisfiesOthers = - currentValue.value === RADIO_OTHERS_INPUT_VALUE && - !!currentValue.othersInput + currentValueTrimmed.value === RADIO_OTHERS_INPUT_VALUE && + !!currentValueTrimmed.othersInput if (satisfiesOthers) return true } - return condValuesArray.includes(String(currentValue.value)) + return condValuesArray.includes(String(currentValueTrimmed.value)) } - return condValuesArray.includes(String(currentValue)) + return condValuesArray.includes(String(currentValueTrimmed)) } case LogicConditionState.Equal: { - if (isRadioFormFieldValue(currentValue, args.fieldType)) { + if (isRadioFormFieldValue(currentValueTrimmed, args.fieldType)) { // It's possible that the condition.value is in a single-valued array. const condValue = Array.isArray(conditionTrimmed.value) ? conditionTrimmed.value[0] : conditionTrimmed.value if ( condValue === 'Others' && - currentValue.value === RADIO_OTHERS_INPUT_VALUE + currentValueTrimmed.value === RADIO_OTHERS_INPUT_VALUE ) { // If the condition value is 'Others', then the condition must be // satisfied if the current value is the special input value. @@ -109,14 +121,14 @@ export const isConditionFulfilled = ( // value created by the user. return true } - return String(condValue) === String(currentValue.value) + return String(condValue) === String(currentValueTrimmed.value) } // In angular, number equality is string=== but decimal equality is number===. // Need to replicate this behavior for backward-compatibility. if (fieldType === BasicField.Decimal) { - return Number(currentValue) === Number(conditionTrimmed.value) + return Number(currentValueTrimmed) === Number(conditionTrimmed.value) } - return String(conditionTrimmed.value) === String(currentValue) + return String(conditionTrimmed.value) === String(currentValueTrimmed) } } } From b44cb570b499d108c71f964b93e3cf083d87caf9 Mon Sep 17 00:00:00 2001 From: tshuli Date: Fri, 17 Mar 2023 18:40:27 +0800 Subject: [PATCH 2/3] fix: trim dropdown options for logic check --- frontend/src/features/logic/utils/isConditionFulfilled.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/features/logic/utils/isConditionFulfilled.ts b/frontend/src/features/logic/utils/isConditionFulfilled.ts index a1d7842b30..3416de86cd 100644 --- a/frontend/src/features/logic/utils/isConditionFulfilled.ts +++ b/frontend/src/features/logic/utils/isConditionFulfilled.ts @@ -67,7 +67,7 @@ export const isConditionFulfilled = ( // TODO #4279: Revisit decision to trim after React rollout is complete let currentValueTrimmed const currentValue = getCurrentFieldValue(args.input, args.fieldType) - if (currentValueTrimmed === '') { + if (currentValue === '') { return false } if (typeof currentValue === 'string') { From faf75b5a7d0d12745e9a0104c541fb66cca17258 Mon Sep 17 00:00:00 2001 From: tshuli Date: Fri, 17 Mar 2023 18:39:23 +0800 Subject: [PATCH 3/3] chore: bump version to 6.36.1 --- CHANGELOG.md | 41 ++++++++++++++++++++++++++--------------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2028c775ce..5913a54fad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -#### [v6.36.0](https://github.com/opengovsg/FormSG/compare/v6.36.0...v6.36.0) +#### [v6.36.1](https://github.com/opengovsg/FormSG/compare/v6.36.0...v6.36.1) + +- build: release v6.36.0 [`#5913`](https://github.com/opengovsg/FormSG/pull/5913) +- fix: trim dropdown options for logic check [`25e197a`](https://github.com/opengovsg/FormSG/commit/25e197a22eecec527b2b284aee0b95ccb1cd3797) #### [v6.36.0](https://github.com/opengovsg/FormSG/compare/v6.35.0...v6.36.0) @@ -20,7 +23,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - chore(deps-dev): bump eslint-config-prettier from 8.6.0 to 8.7.0 in /shared [`#5895`](https://github.com/opengovsg/FormSG/pull/5895) - chore(deps-dev): bump eslint-plugin-simple-import-sort from 8.0.0 to 10.0.0 [`#5771`](https://github.com/opengovsg/FormSG/pull/5771) - chore(deps-dev): bump @typescript-eslint/parser from 5.54.0 to 5.54.1 in /shared [`#5892`](https://github.com/opengovsg/FormSG/pull/5892) -- chore: bump version to v6.36.0 [`a51adf1`](https://github.com/opengovsg/FormSG/commit/a51adf1a129ff473e62f38b6836e5282afc5b83f) +- chore: bump version to v6.36.0 [`d8d2b59`](https://github.com/opengovsg/FormSG/commit/d8d2b59db62d195916a8fcc3d84659dd20687de4) #### [v6.35.0](https://github.com/opengovsg/FormSG/compare/v6.34.0...v6.35.0) @@ -262,7 +265,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [v6.24.0](https://github.com/opengovsg/FormSG/compare/v6.23.3...v6.24.0) -> 23 December 2022 +> 22 December 2022 - feat: initialise datadog in head [`#5571`](https://github.com/opengovsg/FormSG/pull/5571) - build: merge 6.23.3 into develop [`#5614`](https://github.com/opengovsg/FormSG/pull/5614) @@ -299,7 +302,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [v6.23.3](https://github.com/opengovsg/FormSG/compare/v6.23.2...v6.23.3) -> 23 December 2022 +> 22 December 2022 - build: Release v6.23.2 hotfix [`#5602`](https://github.com/opengovsg/FormSG/pull/5602) - chore: bump version to 6.23.2 [`1256707`](https://github.com/opengovsg/FormSG/commit/1256707db95a30486c2ccfc731d9ff6cbdb7dc40) @@ -377,6 +380,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix: extend tags in then show logic blocks to be full width [`#5507`](https://github.com/opengovsg/FormSG/pull/5507) - build: Release v6.20.0 [`#5496`](https://github.com/opengovsg/FormSG/pull/5496) - chore: bump version to v6.21.0 [`3d189cf`](https://github.com/opengovsg/FormSG/commit/3d189cfdc7c105eb31987d31c1b38cb82f402952) +- chore: bump version to v6.20.0 [`54131bd`](https://github.com/opengovsg/FormSG/commit/54131bd9c354fbb9aa478ca871817c34b1544aaa) - chore: fix changelog due to recut in v6.19.0 [`769efee`](https://github.com/opengovsg/FormSG/commit/769efee7d3552d5d675c1b81ed3320a931aafcb8) #### [v6.20.0](https://github.com/opengovsg/FormSG/compare/v6.19.0...v6.20.0) @@ -386,13 +390,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - chore: decommission SAML support for Singpass / Corppass [`#5469`](https://github.com/opengovsg/FormSG/pull/5469) - chore: update chromatic GA to only run in PRs [`#5488`](https://github.com/opengovsg/FormSG/pull/5488) - build: release v6.19.0 [`#5481`](https://github.com/opengovsg/FormSG/pull/5481) -- chore: bump version to v6.20.0 [`54131bd`](https://github.com/opengovsg/FormSG/commit/54131bd9c354fbb9aa478ca871817c34b1544aaa) -- Merge pull request #5490 from opengovsg/release-al2 [`bf0984e`](https://github.com/opengovsg/FormSG/commit/bf0984e8ae74382fd455c0821b16976793990932) - -#### [v6.19.0](https://github.com/opengovsg/FormSG/compare/v6.18.5...v6.19.0) - -> 29 November 2022 - - feat: add public form `/use-template` redirection to admin form template page [`#5486`](https://github.com/opengovsg/FormSG/pull/5486) - fix: remove form title special characters validation [`#5485`](https://github.com/opengovsg/FormSG/pull/5485) - chore: merge hotfix release v6.18.5 to develop [`#5480`](https://github.com/opengovsg/FormSG/pull/5480) @@ -407,15 +404,28 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix: extend MyInfo login expiry to match env var [`#5464`](https://github.com/opengovsg/FormSG/pull/5464) - chore: merge hotfix release v6.18.4 back to develop [`#5472`](https://github.com/opengovsg/FormSG/pull/5472) - feat: improve admin storage mode response printability [`#5460`](https://github.com/opengovsg/FormSG/pull/5460) +- fix: update field validators with more specific type guarantees [`#5468`](https://github.com/opengovsg/FormSG/pull/5468) +- build: hotfix release v6.18.4 [`#5470`](https://github.com/opengovsg/FormSG/pull/5470) +- fix: correctly perform logic validation on MyInfo prefilled fields [`#5467`](https://github.com/opengovsg/FormSG/pull/5467) +- fix: trim dropdown option answer in backend and in angularjs frontend [`#5466`](https://github.com/opengovsg/FormSG/pull/5466) - chore(deps-dev): bump @babel/preset-env from 7.19.4 to 7.20.2 [`#5463`](https://github.com/opengovsg/FormSG/pull/5463) - test: add email submission e2e tests [`#5162`](https://github.com/opengovsg/FormSG/pull/5162) - feat: allow special chars in form title [`#5436`](https://github.com/opengovsg/FormSG/pull/5436) +- fix: release v6.18.3 [`#5459`](https://github.com/opengovsg/FormSG/pull/5459) - chore(deps-dev): bump husky from 8.0.1 to 8.0.2 [`#5457`](https://github.com/opengovsg/FormSG/pull/5457) - fix(docker-compose): change ports from 5000 to 5001 [`#5455`](https://github.com/opengovsg/FormSG/pull/5455) - chore(deps-dev): bump @types/lodash from 4.14.189 to 4.14.190 in /shared [`#5454`](https://github.com/opengovsg/FormSG/pull/5454) - chore(deps-dev): bump @typescript-eslint/eslint-plugin from 5.43.0 to 5.44.0 [`#5453`](https://github.com/opengovsg/FormSG/pull/5453) - fix: update max dimension for image uploads [`#5451`](https://github.com/opengovsg/FormSG/pull/5451) - fix(deps): bump @sentry/browser from 7.17.3 to 7.20.1 [`#5449`](https://github.com/opengovsg/FormSG/pull/5449) +- chore: bump version to v6.20.0 [`1f3f2b7`](https://github.com/opengovsg/FormSG/commit/1f3f2b7fbd0d0fec1980dacbba6a384aeb28b999) +- Merge pull request #5490 from opengovsg/release-al2 [`bf0984e`](https://github.com/opengovsg/FormSG/commit/bf0984e8ae74382fd455c0821b16976793990932) +- fix(deps): bump @aws-sdk/client-cloudwatch-logs to 3.216.0 [`ac812ec`](https://github.com/opengovsg/FormSG/commit/ac812ecdd14b11f9500e3d95aa75050be40d8e24) + +#### [v6.19.0](https://github.com/opengovsg/FormSG/compare/v6.18.5...v6.19.0) + +> 22 November 2022 + - fix: disable submission in template mode [`#5443`](https://github.com/opengovsg/FormSG/pull/5443) - fix(docker-compose): include US and SG SES env vars [`#5442`](https://github.com/opengovsg/FormSG/pull/5442) - feat: use-template for forms [`#5377`](https://github.com/opengovsg/FormSG/pull/5377) @@ -434,7 +444,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix(deps): bump aws-sdk from 2.1251.0 to 2.1255.0 [`#5415`](https://github.com/opengovsg/FormSG/pull/5415) - fix(deps): bump loader-utils from 1.4.0 to 1.4.2 [`#5416`](https://github.com/opengovsg/FormSG/pull/5416) - chore(deps-dev): bump eslint-plugin-jest from 27.1.3 to 27.1.5 [`#5414`](https://github.com/opengovsg/FormSG/pull/5414) -- chore: bump version to v6.19.0 [`f245c66`](https://github.com/opengovsg/FormSG/commit/f245c66f1dbb133429101574889e55b479591061) +- chore: bump version to v6.19.0 [`04762a2`](https://github.com/opengovsg/FormSG/commit/04762a268542a70f3b9d10e1f8c7f273d32ac9bc) - Merge pull request #5435 from opengovsg/release-al2 [`6023bac`](https://github.com/opengovsg/FormSG/commit/6023bac35189418bac8b1bb59cea53661df7fb76) #### [v6.18.5](https://github.com/opengovsg/FormSG/compare/v6.18.4...v6.18.5) @@ -443,16 +453,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix: update field validators with more specific type guarantees [`#5468`](https://github.com/opengovsg/FormSG/pull/5468) - build: hotfix release v6.18.4 [`#5470`](https://github.com/opengovsg/FormSG/pull/5470) +- fix: correctly perform logic validation on MyInfo prefilled fields [`#5467`](https://github.com/opengovsg/FormSG/pull/5467) +- fix: trim dropdown option answer in backend and in angularjs frontend [`#5466`](https://github.com/opengovsg/FormSG/pull/5466) - chore: bump version to 6.18.5 [`d542ca3`](https://github.com/opengovsg/FormSG/commit/d542ca3ba7273ddb1de5aa3cf91bdcff057ead07) +- chore: bump version to v6.18.4 [`fa4b57a`](https://github.com/opengovsg/FormSG/commit/fa4b57a6ff8ed0c5f0aced09733115c32bb2a8ce) #### [v6.18.4](https://github.com/opengovsg/FormSG/compare/v6.18.3...v6.18.4) > 28 November 2022 -- fix: correctly perform logic validation on MyInfo prefilled fields [`#5467`](https://github.com/opengovsg/FormSG/pull/5467) -- fix: trim dropdown option answer in backend and in angularjs frontend [`#5466`](https://github.com/opengovsg/FormSG/pull/5466) - fix: release v6.18.3 [`#5459`](https://github.com/opengovsg/FormSG/pull/5459) -- chore: bump version to v6.18.4 [`fa4b57a`](https://github.com/opengovsg/FormSG/commit/fa4b57a6ff8ed0c5f0aced09733115c32bb2a8ce) +- chore: bump version to v6.18.4 [`704d7b4`](https://github.com/opengovsg/FormSG/commit/704d7b41a263dc774e39f3633a94594def74efef) #### [v6.18.3](https://github.com/opengovsg/FormSG/compare/v6.18.2...v6.18.3) diff --git a/package-lock.json b/package-lock.json index ff2b828ad0..3850ff0329 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FormSG", - "version": "6.36.0", + "version": "6.36.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "FormSG", - "version": "6.36.0", + "version": "6.36.1", "hasInstallScript": true, "dependencies": { "@aws-sdk/client-cloudwatch-logs": "^3.276.0", diff --git a/package.json b/package.json index ba2485e457..e975a343b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "FormSG", "description": "Form Manager for Government", - "version": "6.36.0", + "version": "6.36.1", "homepage": "https://form.gov.sg", "authors": [ "FormSG "