From 7413f5e3c97ebd4e1777089d758afa9079b48f13 Mon Sep 17 00:00:00 2001 From: Kayvon Martinez Date: Thu, 7 Mar 2024 01:07:03 -0600 Subject: [PATCH] Added specific error messages to numeric range field and made character counter field --- .../NumericRangeField/NumericRangeField.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-frontend/src/rjsf/custom_widgets/NumericRangeField/NumericRangeField.tsx b/spiffworkflow-frontend/src/rjsf/custom_widgets/NumericRangeField/NumericRangeField.tsx index dd289a800..db0fdadc9 100644 --- a/spiffworkflow-frontend/src/rjsf/custom_widgets/NumericRangeField/NumericRangeField.tsx +++ b/spiffworkflow-frontend/src/rjsf/custom_widgets/NumericRangeField/NumericRangeField.tsx @@ -66,10 +66,10 @@ export default function NumericRangeField({ // and a decimal point if needed. For example, 1000 will become 1,000 // or 1000.5 will become 1,000.5 - numberString = numberString.replace(/,/g, ''); + const numberStringNoCommas = numberString.replace(/,/g, ''); - if (numberString) { - const parts = numberString.split('.'); + if (numberStringNoCommas) { + const parts = numberStringNoCommas.split('.'); const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ','); return parts.length > 1 ? `${integerPart}.${parts[1]}` : integerPart; } @@ -91,9 +91,9 @@ export default function NumericRangeField({ } const minNumber = schema.minimum; const maxNumber = schema.maximum; - let min = formData?.min; + const min = formData?.min; const [minValue, setMinValue] = React.useState(min?.toString() || ''); - let max = formData?.max; + const max = formData?.max; const [maxValue, setMaxValue] = React.useState(max?.toString() || ''); // the text input eventually breaks when the number gets too big. @@ -102,7 +102,7 @@ export default function NumericRangeField({ const onChangeLocal = (nameToChange: any, event: any) => { event.preventDefault(); - let numberValue = parseNumberString(event.target.value); + const numberValue = parseNumberString(event.target.value); // Validate and update the numeric range based on user input if (nameToChange === 'min') { setMinValue(formatNumberString(numberValue?.toString() || ''));