I have the DisableOnClick of a button set to true, and in its event listener I check some textfields and decided show a popup with an error. In that case the button needs to be enabled again, but setEnabled(true) does not do that. There is no documentation which explains how to re-enable the button.
Sorry I’ve missed this thread. To me this should work and it is a bug in button if it doesn’t. Please create an issue to https://github.com/vaadin/vaadin-button-flow/issues
The essence of my code:
private Button createLoginButton() {
loginButton.addClickListener((event) -> login());
loginButton.setDisableOnClick(true);
return loginButton;
}
final private Button loginButton = new Button("Login");
private void login() {
String username = usernameTextField.getValue();
if (username.isEmpty()) {
U.showErrorDialog("Username is mandatory");
loginButton.setEnabled(true);
return;
}
}