From 74f5d93504681635d2f54bd13806b71c0408b338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Louck=C3=BD?= Date: Fri, 25 Dec 2020 01:39:49 +0100 Subject: [PATCH] Display up-to-date error messages under text fields As user types into a validated text field, if the new string is still invalid but the error message changed, ensure the new message will be displayed. --- .../java/bisq/core/util/validation/InputValidator.java | 7 +++++++ .../main/java/bisq/desktop/components/InputTextField.java | 3 +++ 2 files changed, 10 insertions(+) diff --git a/core/src/main/java/bisq/core/util/validation/InputValidator.java b/core/src/main/java/bisq/core/util/validation/InputValidator.java index 7fee474daae..7ce3d68a5eb 100644 --- a/core/src/main/java/bisq/core/util/validation/InputValidator.java +++ b/core/src/main/java/bisq/core/util/validation/InputValidator.java @@ -21,6 +21,7 @@ import java.math.BigInteger; +import java.util.Objects; import java.util.function.Function; public class InputValidator { @@ -65,6 +66,12 @@ public String toString() { '}'; } + public boolean errorMessageEquals(ValidationResult other) { + if (this == other) return true; + if (other == null) return false; + return Objects.equals(errorMessage, other.errorMessage); + } + public interface Validator extends Function { } diff --git a/desktop/src/main/java/bisq/desktop/components/InputTextField.java b/desktop/src/main/java/bisq/desktop/components/InputTextField.java index abe9b49468b..73130745062 100644 --- a/desktop/src/main/java/bisq/desktop/components/InputTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/InputTextField.java @@ -78,6 +78,9 @@ public InputTextField() { if (newValue != null) { resetValidation(); if (!newValue.isValid) { + if (!newValue.errorMessageEquals(oldValue)) { // avoid blinking + validate(); // ensure that the new error message replaces the old one + } if (this.errorMessage != null) { jfxValidationWrapper.applyErrorMessage(this.errorMessage); } else {