From 05b25cfe82e28199f849d1e2d2f06538b6edf194 Mon Sep 17 00:00:00 2001 From: Devanshu Rastogi Date: Wed, 4 Dec 2024 13:52:33 +0530 Subject: [PATCH] Fixed value of value CSA when no default value is set and clear() action is used. (#11409) --- .../src/AppBuilder/WidgetManager/widgets/numberinput.js | 2 +- frontend/src/Editor/Components/NumberInput.jsx | 7 ++++++- frontend/src/Editor/WidgetManager/configs/numberinput.js | 2 +- server/src/helpers/widget-config/numberinput.js | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/numberinput.js b/frontend/src/AppBuilder/WidgetManager/widgets/numberinput.js index ba7f2bc227..b0f72e6d81 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/numberinput.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/numberinput.js @@ -236,7 +236,7 @@ export const numberinputConfig = { }, ], exposedVariables: { - value: 99, + value: 0, isMandatory: false, isVisible: true, isDisabled: false, diff --git a/frontend/src/Editor/Components/NumberInput.jsx b/frontend/src/Editor/Components/NumberInput.jsx index 5a130bf5cc..0092893734 100644 --- a/frontend/src/Editor/Components/NumberInput.jsx +++ b/frontend/src/Editor/Components/NumberInput.jsx @@ -72,6 +72,9 @@ export const NumberInput = function NumberInput({ useEffect(() => { setInputValue(Number(parseFloat(properties.value).toFixed(properties.decimalPlaces))); + if (isNaN(Number(parseFloat(properties.value).toFixed(properties.decimalPlaces)))) { + setExposedVariable('value', null); + } // eslint-disable-next-line react-hooks/exhaustive-deps }, [properties.value]); @@ -144,6 +147,7 @@ export const NumberInput = function NumberInput({ }, clear: async function () { setInputValue(''); + setExposedVariable('value', null); fireEvent('onChange'); }, setLoading: async function (loading) { @@ -167,7 +171,8 @@ export const NumberInput = function NumberInput({ }; if (!isNaN(value)) { exposedVariables.value = value; - } + } else exposedVariables.value = null; + setExposedVariables(exposedVariables); isInitialRender.current = false; diff --git a/frontend/src/Editor/WidgetManager/configs/numberinput.js b/frontend/src/Editor/WidgetManager/configs/numberinput.js index 148754d5be..f5bc2b1490 100644 --- a/frontend/src/Editor/WidgetManager/configs/numberinput.js +++ b/frontend/src/Editor/WidgetManager/configs/numberinput.js @@ -236,7 +236,7 @@ export const numberinputConfig = { }, ], exposedVariables: { - value: 99, + value: 0, isMandatory: false, isVisible: true, isDisabled: false, diff --git a/server/src/helpers/widget-config/numberinput.js b/server/src/helpers/widget-config/numberinput.js index ba7f2bc227..b0f72e6d81 100644 --- a/server/src/helpers/widget-config/numberinput.js +++ b/server/src/helpers/widget-config/numberinput.js @@ -236,7 +236,7 @@ export const numberinputConfig = { }, ], exposedVariables: { - value: 99, + value: 0, isMandatory: false, isVisible: true, isDisabled: false,