Skip to content

Commit

Permalink
fix: do not throw when min is set to negative infinity (#6246) (#6251)
Browse files Browse the repository at this point in the history
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan committed Apr 26, 2024
1 parent 46dcac2 commit e8ead46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ private boolean isValidByStep(T value) {
// When min is not defined by user, its value is the absoluteMin
// provided in constructor. In this case, min should not be considered
// in the step validation.
double stepBasis = minSetByUser ? getMinDouble() : 0.0;
double stepBasis = minSetByUser && !Double.isInfinite(getMinDouble())
? getMinDouble()
: 0.0;

// (value - stepBasis) % step == 0
return new BigDecimal(String.valueOf(value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ public void stepValidation_negativeMin_minUsedAsStepBasis() {
assertInvalidValues(-4.5, 0.0, 1.0, 4.5);
}

@Test
public void setMinNegativeInfinity_doesNotThrow() {
field.setStep(1.0);
field.setMin(Double.NEGATIVE_INFINITY);
field.setValue(6.0);
}

@Override
@Test
public void elementHasValue_wrapIntoTextField_propertyIsNotSetToInitialValue() {
Expand Down

0 comments on commit e8ead46

Please sign in to comment.