Skip to content

Commit

Permalink
fix: reactive forms not updating on changes in store (angular-redux#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal authored and smithad15 committed Jul 9, 2018
1 parent 6544ca8 commit bd87846
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/form/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

0 comments on commit bd87846

Please sign in to comment.