From 64251137663906c4b4ce69b24e474e0d665efb8f Mon Sep 17 00:00:00 2001 From: Shemy Gan Date: Wed, 23 Oct 2024 13:18:00 -0400 Subject: [PATCH] - add OnBlur to Field and Select - update regex to remove dot for jwtttl --- Client/src/Components/Inputs/Field/index.jsx | 3 +++ Client/src/Components/Inputs/Select/index.jsx | 3 +++ Client/src/Pages/AdvancedSettings/index.jsx | 25 +++++++++++++++---- Client/src/Validation/validation.js | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx index 1b5ab0c7c..dfcdb5920 100644 --- a/Client/src/Components/Inputs/Field/index.jsx +++ b/Client/src/Components/Inputs/Field/index.jsx @@ -41,6 +41,7 @@ const Field = forwardRef( placeholder, value, onChange, + onBlur, onInput, error, disabled, @@ -115,6 +116,7 @@ const Field = forwardRef( value={value} onInput={onInput} onChange={onChange} + onBlur={onBlur} disabled={disabled} inputRef={ref} inputProps={{ @@ -216,6 +218,7 @@ Field.propTypes = { placeholder: PropTypes.string, value: PropTypes.string.isRequired, onChange: PropTypes.func, + onBlur: PropTypes.func, onInput: PropTypes.func, error: PropTypes.string, disabled: PropTypes.bool, diff --git a/Client/src/Components/Inputs/Select/index.jsx b/Client/src/Components/Inputs/Select/index.jsx index e470881ec..8517c3214 100644 --- a/Client/src/Components/Inputs/Select/index.jsx +++ b/Client/src/Components/Inputs/Select/index.jsx @@ -46,6 +46,7 @@ const Select = ({ value, items, onChange, + onBlur, sx, name = "", }) => { @@ -76,6 +77,7 @@ const Select = ({ className="select-component" value={value} onChange={onChange} + onBlur={onBlur} displayEmpty name={name} inputProps={{ id: id }} @@ -140,6 +142,7 @@ Select.propTypes = { }) ).isRequired, onChange: PropTypes.func.isRequired, + onBlur: PropTypes.func, sx: PropTypes.object, }; diff --git a/Client/src/Pages/AdvancedSettings/index.jsx b/Client/src/Pages/AdvancedSettings/index.jsx index b71123ca7..d5ac22b26 100644 --- a/Client/src/Pages/AdvancedSettings/index.jsx +++ b/Client/src/Pages/AdvancedSettings/index.jsx @@ -74,18 +74,23 @@ const AdvancedSettings = ({ isAdmin }) => { setLocalSettings({ ...localSettings, logLevel: newLogLevel }); }; - const handleChange = (event) => { + const handleBlur = (event) => { const { value, id } = event.target; - setLocalSettings({ ...localSettings, [id]: value }); const { error } = advancedSettingsValidation.validate( { [id]: value }, { abortEarly: false, } ); - setErrors((prev) => { - return buildErrors(prev, id, error); - }); + if (error) { + setErrors((prev) => { + return buildErrors(prev, id, error); + }); + } + }; + const handleChange = (event) => { + const { value, id } = event.target; + setLocalSettings({ ...localSettings, [id]: value }); }; const handleSave = async () => { @@ -131,6 +136,7 @@ const AdvancedSettings = ({ isAdmin }) => { label="API URL Host" value={localSettings.apiBaseUrl} onChange={handleChange} + onBlur={handleBlur} error={errors.apiBaseUrl} />