Skip to content

fix: reactive forms not updating on changes in store #41

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

Merged
merged 1 commit into from
Jan 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions source/connect/connect-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export class ConnectBase {
throw new Error(`Unknown type of form element: ${formElement.constructor.name}`);
}

return pairs.filter(p => (<any>p.control)._parent === this.form.control);
return pairs.filter(p => {
const parent = (p.control as any)._parent;
return parent === this.form.control || parent === this.form;
});
}

private resetState() {
Expand All @@ -114,12 +117,10 @@ export class ConnectBase {
children.forEach(c => {
const { path, control } = c;

const value = State.get(this.getState(), this.path.concat(c.path));
const value = State.get(this.getState(), this.path.concat(path));

if (control.value !== value) {
const phonyControl = <any>{ path: path };

this.form.updateModel(phonyControl, value);
control.setValue(value);
}
});
}
Expand Down