Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not clear error message when the field becomes valid #3439

Closed
denis-anisimov opened this issue Jan 30, 2018 · 3 comments
Closed

Do not clear error message when the field becomes valid #3439

denis-anisimov opened this issue Jan 30, 2018 · 3 comments

Comments

@denis-anisimov
Copy link
Contributor

@jouni commented on Tue Oct 24 2017

When the field becomes valid, the error message is cleared and removed from the DOM. This can cause issues with themes that expect the error message to remain in the DOM, for the purpose of transitions/animations.

The vaadin-text-field element hides the error message automatically when the field is valid, so there shouldn’t be a need to remove the text content of the message:
https://github.com/vaadin/vaadin-text-field/blob/master/vaadin-text-field.html#L130

Here’s the unwanted behavior - the error message vanishes too quickly:
error-message-removed

Here’s the desired behavior – the error message is nicely curtained/collapsed:
error-message-not-removed

This could also be a Vaadin Flow Binder issue, so feel free to move it to a more appropriate repo if needed.


@denis-anisimov commented on Tue Jan 30 2018

That's the Flow binder issue definitely.
There is a code that clears the error message when the field should become valid.

The problem here is that it's the common behavior: binder doesn't distinguish text field or any other component.
It executes the logic for any HasValidation component.
As a result there is the question: is it true that it's enough to update only the status without the error message for any component which allows to set error message and "valid/invalid" status ?

@pleku
Copy link
Contributor

pleku commented Jan 30, 2018

As a result there is the question: is it true that it's enough to update only the status without the error message for any component which allows to set error message and "valid/invalid" status ?

I think we can trust that, as @jouni stated that is how it works for Vaadin Elements and I tested also <paper-input> to work the similar way.

The javadocs for setErrorMessage(String errorMessage) should probably be updated to reflect this, like The Web Component is responsible for deciding when to show the error message to the user, and this is usually triggered by triggering the invalid state for the Web Component`

@jouni
Copy link
Member

jouni commented Jan 30, 2018

Yeah, I think we can make a design decision, that we treat error messages the same as tooltips, that they are only shown to the user when needed, not always. I agree that this is might not be completely obvious to all users. But it’s easy to argue, that there shouldn’t be a need to show an error message if a field is valid.

A “description” or “hint text” is also similar, that it could be shown only when the field is not invalid and it is replaced with the error message when the field is invalid.

@denis-anisimov denis-anisimov self-assigned this Feb 13, 2018
denis-anisimov pushed a commit that referenced this issue Feb 14, 2018
* Don't remove error message when the field becomes valid

Fix for #3439
@pleku pleku closed this as completed Feb 15, 2018
@SomeoneToIgnore SomeoneToIgnore added this to the 1.0.0.alpha21 milestone Feb 15, 2018
@denis-anisimov
Copy link
Contributor Author

denis-anisimov commented Feb 20, 2018

As a result the assumption is wrong for TextField e.g.
When I use text field with the Binder and has a validator then
invalid text filed doesn't hide the error message when it becomes valid.

I will create a ticket against Flow but as I understand this is the issue in vaadin-text-feild.
Will create a ticket for it as well.

https://github.com/vaadin/vaadin-text-field-flow/issues/56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants