fix(kit): ComboBox
throws ExpressionChangedAfterItHasBeenCheckedError
#1772
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Simplified version of the bug’s reproduction:
HTML
Typescript
What's happening
https://github.com/Tinkoff/taiga-ui/blob/d82ab19a9598ec47469b0d218b514c4ddd78263e/projects/kit/components/combo-box/combo-box.component.ts#L181-L198
Controller is not changed (it was
null
and after this function it is stillnull
). It is still pristine.No item is selected because
procedures$
(inside ourExampleComponent
) is empty. After that functiononSearchProcedureChange
(inside ourExampleComponent
) is triggered and fillsprocedures$
with two new items (prop[items]
inside<tui-data-list-wrapper />
changes).Tick happens! (all next steps happens in the same tick).
Angular evaluates
pristine
-status astrue
inside this built-in form-controller directive.Angular renders new
SelectOption
-s and theirngOnInit
were triggered:https://github.com/Tinkoff/taiga-ui/blob/68ab06940351262f9468165d5c4a3aa1046d5696/projects/kit/components/select-option/select-option.component.ts#L52-L56
They invoke
checkOption
-functions of the parent component.https://github.com/Tinkoff/taiga-ui/blob/d82ab19a9598ec47469b0d218b514c4ddd78263e/projects/kit/components/combo-box/combo-box.component.ts#L148-L155
And
this.updateValue(option)
makes controldirty
.pristine
wastrue
but at the end it isfalse
. Angular throws error.Closes #1643
What is the new behavior?
Does this PR introduce a breaking change?