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

ownError for IState #71

Closed
nighca opened this issue Feb 25, 2022 · 0 comments · Fixed by #70
Closed

ownError for IState #71

nighca opened this issue Feb 25, 2022 · 0 comments · Fixed by #70
Assignees
Labels
v3 Version 3

Comments

@nighca
Copy link
Collaborator

nighca commented Feb 25, 2022

When we do UI binding for validate status, such as error tip showing, invalid highlighting. Most of the time it produces UI like:

image

image

If the bound state is composed with child states, which means the child states may have been bound to some child inputs or error tips. It's not necessary to show child states' error at parent level—that will introduce duplication.

Here is an example of FullNameInput, which consists of input for first name & input for last name. If we use error (& hasError) for UI binding, the error of first name (Please input!) will be shown at both child level & parent level:

image

That's why ownError (& hasOwnError) is needed.

  • ownError: The state's own error info, regardless of child states.
  • hasOwnError: If the state contains its own error info.

We will always prefer to use ownError (& hasOwnError) for UI binding. That will help to avoid error duplication.

Previously we provide ownError (& hasOwnError) for FormState (& ArrayFormState) only. While considering a instance of DebouncedState or TransformedState, which wraps a FormState instance, ownError is also needed for it. In the future, we may provide more state types just like DebouncedState & TransformedState, for whom ownError is also needed.

That's why I think we should put it on interface IState.

@nighca nighca added the v3 Version 3 label Feb 25, 2022
@nighca nighca self-assigned this Feb 25, 2022
@nighca nighca linked a pull request Feb 25, 2022 that will close this issue
@nighca nighca mentioned this issue Feb 25, 2022
Merged
13 tasks
@nighca nighca closed this as completed Mar 4, 2022
@nighca nighca mentioned this issue Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 Version 3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant