From de9134106b2b5731be12148490630862477ea3b9 Mon Sep 17 00:00:00 2001 From: yashgoyal-groww Date: Wed, 17 Jan 2024 13:04:47 +0530 Subject: [PATCH 1/3] Resolve Memory Leaks in Select and Dropdown Components --- .../ui-toolkit/src/components/atoms/Dropdown/Dropdown.tsx | 2 +- packages/ui-toolkit/src/components/atoms/Select/Select.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/ui-toolkit/src/components/atoms/Dropdown/Dropdown.tsx b/packages/ui-toolkit/src/components/atoms/Dropdown/Dropdown.tsx index 3b5f588b..c8c6eadc 100644 --- a/packages/ui-toolkit/src/components/atoms/Dropdown/Dropdown.tsx +++ b/packages/ui-toolkit/src/components/atoms/Dropdown/Dropdown.tsx @@ -29,7 +29,7 @@ class Dropdown extends React.PureComponent { componentWillUnmount() { document.removeEventListener('click', this._onWindowClick); document.removeEventListener('touchstart', this._onWindowClick); - document.removeEventListener('keyup', this._onKeyDownHandler); + document.removeEventListener('keydown', this._onKeyDownHandler); } diff --git a/packages/ui-toolkit/src/components/atoms/Select/Select.tsx b/packages/ui-toolkit/src/components/atoms/Select/Select.tsx index db6a4cbc..b453d558 100644 --- a/packages/ui-toolkit/src/components/atoms/Select/Select.tsx +++ b/packages/ui-toolkit/src/components/atoms/Select/Select.tsx @@ -39,6 +39,13 @@ class Select extends React.PureComponent { } + componentWillUnmount() { + //@ts-ignore + this.optionsRefArr.forEach(ref => (ref.current = null)); + this.optionsRefArr = []; + } + + render() { const { data: options } = this.props; From f352b48335c0a09f7de20de6737c118e290f3d10 Mon Sep 17 00:00:00 2001 From: yashgoyal-groww Date: Mon, 29 Jan 2024 12:54:12 +0530 Subject: [PATCH 2/3] Remove ts-ignore --- packages/ui-toolkit/src/components/atoms/Select/Select.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ui-toolkit/src/components/atoms/Select/Select.tsx b/packages/ui-toolkit/src/components/atoms/Select/Select.tsx index b453d558..9b84b214 100644 --- a/packages/ui-toolkit/src/components/atoms/Select/Select.tsx +++ b/packages/ui-toolkit/src/components/atoms/Select/Select.tsx @@ -40,9 +40,9 @@ class Select extends React.PureComponent { componentWillUnmount() { - //@ts-ignore - this.optionsRefArr.forEach(ref => (ref.current = null)); + this.optionsRefArr.forEach((ref: any) => (ref.current = null)); this.optionsRefArr = []; + this.selectDropdownRef = null; } From de16d68b6ce449a3c0d2498c9fd7dc426b9b3b50 Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Thu, 1 Feb 2024 17:02:41 +0530 Subject: [PATCH 3/3] bump ui toolkit to v0.5.5 --- packages/ui-toolkit/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui-toolkit/package.json b/packages/ui-toolkit/package.json index d5c912f7..4a0cdd0c 100644 --- a/packages/ui-toolkit/package.json +++ b/packages/ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@groww-tech/ui-toolkit", - "version": "0.5.4", + "version": "0.5.5", "description": "A lightning nature UI", "main": "dist/cjs/index.js", "module": "dist/esm/index.js",