Numeric range tweaks (#1445)

* tweaks to help with layout for numeric ranges

* use negative infinity for min

* remove some debug code

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2024-04-24 16:04:55 +00:00 committed by GitHub
parent ae502e50d7
commit f773823008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View File

@ -262,9 +262,7 @@ export default function CustomForm({
(formDataToCheck[propertyKey].min === undefined || (formDataToCheck[propertyKey].min === undefined ||
formDataToCheck[propertyKey].max === undefined) formDataToCheck[propertyKey].max === undefined)
) { ) {
errors[propertyKey].addError( errors[propertyKey].addError('must have valid Minimum and Maximum');
`must have valid Minimum and Maximum on ${propertyKey}`
);
} }
if ( if (
formDataToCheck[propertyKey].min < formDataToCheck[propertyKey].min <

View File

@ -117,17 +117,19 @@ export default function NumericRangeField({
}; };
let minHelperText = ''; let minHelperText = '';
if (minNumber !== undefined) {
minHelperText = `Min: ${formatNumberString(minNumber?.toString() || '')}`;
}
let maxHelperText = ''; let maxHelperText = '';
if (maxNumber !== undefined) { if (minNumber !== undefined || maxNumber !== undefined) {
maxHelperText = `Max: ${formatNumberString(maxNumber?.toString() || '')}`; minHelperText = `Min: ${
formatNumberString(minNumber?.toString() || '') || '-∞'
}`;
maxHelperText = `Max: ${
formatNumberString(maxNumber?.toString() || '') || '∞'
}`;
} }
return ( return (
<div className="numeric--range-field-wrapper"> <div className="numeric--range-field-wrapper">
<div className="numeric--range-field-label"> <div>
<h5> <h5>
{required {required
? commonAttributes.labelWithRequiredIndicator ? commonAttributes.labelWithRequiredIndicator