From 6b947ad868156e3890978ed2a0778b5c73b6edfc Mon Sep 17 00:00:00 2001 From: Ken Lee Shu Ming Date: Thu, 7 Nov 2024 11:46:04 +0800 Subject: [PATCH 1/2] fix: use settimeout instead of debounce (#7856) --- .../ChildrenCompound/ChildrenCompoundField.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/templates/Field/ChildrenCompound/ChildrenCompoundField.tsx b/frontend/src/templates/Field/ChildrenCompound/ChildrenCompoundField.tsx index 28eb38d79e..17befdb2fb 100644 --- a/frontend/src/templates/Field/ChildrenCompound/ChildrenCompoundField.tsx +++ b/frontend/src/templates/Field/ChildrenCompound/ChildrenCompoundField.tsx @@ -21,7 +21,7 @@ import { VisuallyHidden, VStack, } from '@chakra-ui/react' -import { debounce, get } from 'lodash' +import { get } from 'lodash' import simplur from 'simplur' import { DATE_DISPLAY_FORMAT } from '~shared/constants/dates' @@ -439,15 +439,20 @@ const ChildrenBody = ({ items={ MYINFO_ATTRIBUTE_MAP[subField].fieldOptions as string[] } - onChange={debounce( - (option) => + onChange={(option) => { + // prevent updates if there's no change to the values + // there's an infinite loop on the update + // upgrading to v8.xx, or v9.xx doesn't seem to have resolved the issue + // https://github.com/downshift-js/downshift/issues/1511#issuecomment-1598307130 + + setTimeout(() => // This is bad practice but we have no choice because our // custom Select doesn't forward the event. // FIXME: Fix types + // @ts-expect-error type inference issue setValue(fieldPath, option, { shouldValidate: true }), - 200, - { leading: true }, - )} + ) + }} /> {childrenSubFieldError?.message} From 11b8b6122465e62b7fb1ee636be5504e67bb9576 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 7 Nov 2024 14:06:16 +0800 Subject: [PATCH 2/2] 6.158.2 --- CHANGELOG.md | 8 ++++++++ frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ceec244088..d1251f81ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,18 @@ 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.158.2](https://github.com/opengovsg/FormSG/compare/v6.158.1...v6.158.2) + +- fix: use settimeout instead of debounce [`#7856`](https://github.com/opengovsg/FormSG/pull/7856) +- fix: add debounce to break infinite call loop (#7848) [`#7849`](https://github.com/opengovsg/FormSG/pull/7849) + #### [v6.158.1](https://github.com/opengovsg/FormSG/compare/v6.158.0...v6.158.1) +> 5 November 2024 + - fix: add debounce to break infinite call loop [`#7848`](https://github.com/opengovsg/FormSG/pull/7848) - build: release v6.158.0 [`#7847`](https://github.com/opengovsg/FormSG/pull/7847) +- build: release 6.158.1 [`1a9c868`](https://github.com/opengovsg/FormSG/commit/1a9c868d4c2e3b15229a331c5e1e64cf48b58de2) #### [v6.158.0](https://github.com/opengovsg/FormSG/compare/v6.157.0...v6.158.0) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index dbdee57bf6..486dc9cfe0 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "form-frontend", - "version": "6.158.1", + "version": "6.158.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "form-frontend", - "version": "6.158.1", + "version": "6.158.2", "hasInstallScript": true, "dependencies": { "@chakra-ui/react": "^2.8.2", diff --git a/frontend/package.json b/frontend/package.json index c41d186b08..1b756503d0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "form-frontend", - "version": "6.158.1", + "version": "6.158.2", "homepage": ".", "type": "module", "private": true, diff --git a/package-lock.json b/package-lock.json index a5ae34a81d..f171aafdd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FormSG", - "version": "6.158.1", + "version": "6.158.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "FormSG", - "version": "6.158.1", + "version": "6.158.2", "hasInstallScript": true, "dependencies": { "@aws-sdk/client-cloudwatch-logs": "^3.536.0", diff --git a/package.json b/package.json index a458053205..3ed294cc38 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "FormSG", "description": "Form Manager for Government", - "version": "6.158.1", + "version": "6.158.2", "homepage": "https://form.gov.sg", "authors": [ "FormSG "