From 3ea785b45c2f53a7e3d7521060de6f8b687fbb00 Mon Sep 17 00:00:00 2001 From: Eshank Vaish <48060426+eshankvaish@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:16:44 +0530 Subject: [PATCH] fix: on change being called in custom input without any change --- package-lock.json | 4 ++-- package.json | 2 +- src/Common/CustomInput/CustomInput.tsx | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb752893a..8780bc14b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "license": "ISC", "dependencies": { "@types/react-dates": "^21.8.6", diff --git a/package.json b/package.json index 02a81b5fa..e38e61d23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.0.10", + "version": "1.0.11", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/CustomInput/CustomInput.tsx b/src/Common/CustomInput/CustomInput.tsx index 00c71316f..fdc0cbbad 100644 --- a/src/Common/CustomInput/CustomInput.tsx +++ b/src/Common/CustomInput/CustomInput.tsx @@ -69,9 +69,13 @@ export const CustomInput = ({ const handleOnBlur = (event) => { // NOTE: This is to prevent the input from being trimmed when the user do not want to trim the input if (!noTrim) { - event.stopPropagation() - event.target.value = event.target.value?.trim() - onChange(event) + const trimmedValue = event.target.value?.trim() + + if (event.target.value !== trimmedValue) { + event.stopPropagation() + event.target.value = trimmedValue + onChange(event) + } } if (typeof onBlur === 'function') { onBlur(event)