Unable to start typing negative number in `NumberFieldController`
senseiwells opened this issue ยท 0 comments
You currently cannot start typing a negative number in a NumberFieldController
, you can work around this by typing the absolute value then prepending a -
afterwards.
Seems like this was previously an issue: #72, but has been re-introduced.
A suggested fix would be:
@Override
public boolean isInputValid(String input) {
if (min() < 0 && "-".equals(input)) {
return true;
}
input = input.replace(DECIMAL_FORMAT_SYMBOLS.getGroupingSeparator() + "", "");
ParsePosition parsePosition = new ParsePosition(0);
NUMBER_FORMAT.parse(input, parsePosition);
return parsePosition.getIndex() == input.length();
}