Skip to content

Commit b46bb5a

Browse files
Peter Leibigerkuhnroyal
Peter Leibiger
authored andcommitted
fix: reactive forms not updating on changes in store
Signed-off-by: Peter Leibiger <[email protected]>
1 parent 146d93d commit b46bb5a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

source/connect/connect-base.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export class ConnectBase {
9797
throw new Error(`Unknown type of form element: ${formElement.constructor.name}`);
9898
}
9999

100-
return pairs.filter(p => (<any>p.control)._parent === this.form.control);
100+
return pairs.filter(p => {
101+
const parent = (p.control as any)._parent;
102+
return parent === this.form.control || parent === this.form;
103+
});
101104
}
102105

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

117-
const value = State.get(this.getState(), this.path.concat(c.path));
120+
const value = State.get(this.getState(), this.path.concat(path));
118121

119122
if (control.value !== value) {
120-
const phonyControl = <any>{ path: path };
121-
122-
this.form.updateModel(phonyControl, value);
123+
control.setValue(value);
123124
}
124125
});
125126
}

0 commit comments

Comments
 (0)