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
Issues with Validation #2964
Comments
I'm going to attempt to implement solution B (once #2781 is merged) and I'll see what comes out of it. In the mean time, any one who has anything to say please do, because I don't want to miss anything. |
There are public APIs to get focus state if that is required. The Canvas can be asked what is focused and we can see if that is the same as the object you are curious about. |
I don’t agree with this amendment, it is imposing render info onto internal state. As discussed on the call earlier it is strange that a form showing an error text for an entry will reset when the entry gains focus. Form and entry should not be as tightly coupled as they are. |
I don't like it either, but I wasn't sure how to determine what is focused. Could you elaborate on how you would do that, cause I'm not really able to figure out how that would work. |
New note:
|
Let's not extend the scope of things more than required. |
Fair enough. I don't think I'm gonna remove it (for posterity's sake), but that should be fine. |
While I agree that form and entry shouldn't be as coupled as they are, some of the UX that results from this is useful and very user friendly. So I would like to preserve that behavior somehow, just without the tight coupling. I agree that this amendment isn't a good way to do it, so maybe we could do it by using error wrapping. If the entry is focused the validation error could wrap (or be wrapped) by a |
This is based on a discussion I had with @andydotxyz on discord.
TL;DR: Currently,
Form
s do not treat validation as a black box, and contain special behavior for anEntry
.The problem with just removing this behavior is that we need to do something different to ensure that we don't startle the end user with errors until they interact with them and currently this works by affecting the internal state of an
Entry
.The question at hand is: How can we fix this so a
Form
exhibits the same behavior for allValidator
s and can it be done without changing theValidator
interface?Problem:
We have two categories in validation: Producers (
Validator
s) and Consumers (any thing that usesSetOnValidationError()
).The contract for producers and consumers (and the user) is as follows:
The current problem is two-fold:
Entry
and the consumer is aForm
.To be clear: on a lower level, currently this contract is only fulfilled from the end user's stand point and not internally.
Solutions:
Solution A:
Add
SetValidationError()
to theValidator
interface and set an initial error on the children. This fulfills the contract by using an error that everything knows to ignore, but also is still an invalid state.Pros:
Entry
s, so it should work elsewhere (considering that it is the reference implementation for otherValidator
s).Cons:
Ultimately, this solution is probably the wrong one and therefore:
Solution B:
Fully divorce the presentation of the error from the (change in) state of it. So when the widget is first rendered it will not show anything alerting (i.e. red colored) until
Validate()
has been called.Pros:
Validator
as a black box (like it should be).Cons:
Notes:
Different reactions based on state of user interaction:
There is reason to amend the the third rule of the contract to:
If we accept this change (which
Form
andEntry
already adheres to), this will complicate how the state is passed on.The problem with the way
Form
does it, is that is gets the internal state fromEntry
(by virtue of being in the same package) to determine if theEntry
is focused. This causes it not to work on anything other than an actualEntry
. So one way to fix this would be to add a clause to the first rule:However, this would mean that the validation state (at least in the consumer) isn't updated at all until after the user is no longer interacting with the producer, which is no good. It is useful for a consumer to demonstrate that the producer state is valid (ex. the submit button on a
Form
is enabled as soon as valid input is provided), so there needs to be some way to pass up that the state has changed while also including the fact that it hasn't finished changing (or something like that, i.e. the widget is still focused), or there needs to be a way to determine it's still being edited.Multiple Consumers:
Another question is should
SetOnValidationChanged()
not overwrite previously set callbacks? This would add a clause to the first rule:Additionally, this would likely require adding a
Delete()
method to theValidator
interface, or to just create a new interface (something likeMultipleParentValidator
) that includesDelete()
. The second method is fine as it is makes no real difference to a parent as long as it receives an update. But honestly, I don't think being able to delete a callback is strictly required.The text was updated successfully, but these errors were encountered: