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

Can't set TextFieldBlocState.error to null after successful validation #342

Open
Oleg3n opened this issue Dec 16, 2023 · 1 comment
Open

Comments

@Oleg3n
Copy link

Oleg3n commented Dec 16, 2023

In a scenario when editing an already existing record, there is a need to initialize initial values for FieldBlocs. The first validation seems to happen on creating FormBloc. Values are empty at that point, so if field is required, State.error has error message. When SingleFieldBloc.updateInitialValue performs successful validation of new value, it calls

emit(state.copyWith(
...
error: Param(error),
...
))

where error is NULL.
The TextFieldBlocState.copyWith implementation is like this:

error: error == null ? this.error : error.value,

so when error is NULL it just keeps an old error message instead of reset it to null. As result the valid form submission fails.

@vasilich6107
Copy link

#312 (comment)

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

No branches or pull requests

2 participants