some additional fixes for the numeric range field (#1464)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2024-04-29 20:04:21 +00:00 committed by GitHub
parent 23e147793a
commit 1495b7dac8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View File

@ -266,8 +266,8 @@ export default function CustomForm({
errors[propertyKey].addError('must have valid Minimum and Maximum'); errors[propertyKey].addError('must have valid Minimum and Maximum');
} }
if ( if (
!formDataToCheck[propertyKey].min.toString().match(matchNumberRegex) || !formDataToCheck[propertyKey].min?.toString().match(matchNumberRegex) ||
!formDataToCheck[propertyKey].max.toString().match(matchNumberRegex) !formDataToCheck[propertyKey].max?.toString().match(matchNumberRegex)
) { ) {
errors[propertyKey].addError('must have valid numbers'); errors[propertyKey].addError('must have valid numbers');
} }

View File

@ -9,7 +9,7 @@ export const doNothing = () => {
return undefined; return undefined;
}; };
export const matchNumberRegex = /^[0-9,.]*$/; export const matchNumberRegex = /^[0-9,.-]*$/;
// https://www.30secondsofcode.org/js/s/slugify // https://www.30secondsofcode.org/js/s/slugify
export const slugifyString = (str: string) => { export const slugifyString = (str: string) => {

View File

@ -166,6 +166,7 @@ export default function NumericRangeField({
setMinValue(event.target.value); setMinValue(event.target.value);
}} }}
invalid={commonAttributes.invalid} invalid={commonAttributes.invalid}
invalidText={minHelperText}
helperText={minHelperText} helperText={minHelperText}
autofocus={autofocus} autofocus={autofocus}
/> />
@ -181,6 +182,7 @@ export default function NumericRangeField({
setMaxValue(event.target.value); setMaxValue(event.target.value);
}} }}
invalid={commonAttributes.invalid} invalid={commonAttributes.invalid}
invalidText={maxHelperText}
helperText={maxHelperText} helperText={maxHelperText}
/> />
</div> </div>