We should be setting the max length limit before we set the value, otherwise the text will be shrunk in the EditBox#setValue method.
public void setValue(String text) {
if (this.filter.test(text)) {
if (text.length() > this.maxLength) {
this.value = text.substring(0, this.maxLength);
} else {
this.value = text;
}
this.moveCursorToEnd();
this.setHighlightPos(this.cursorPos);
this.onValueChange(text);
}
}
Originally we call setValue first, and only then follow it with setMaxLength, the text is already shrunk at that point.
This PR prioritizes setting the max length first to avoid this issue.
We should be setting the max length limit before we set the value, otherwise the text will be shrunk in the EditBox#setValue method.
Originally we call setValue first, and only then follow it with setMaxLength, the text is already shrunk at that point. This PR prioritizes setting the max length first to avoid this issue.