angular: AbstractControl enable/disable does not pass emitEvent to this._updateAncestors()

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request

Current behavior

Enabling/disabling AbstractControl descendant emits new value in valueChanges stream regardless value of emitEvent passed in object as parameter of enable() / disable().

Expected behavior

No new object emitted by valueChanges.

Minimal reproduction of the problem with instructions

Create form with 2 controls. Subscribe to form valueChanges stream. In this function disable second control based on value of first control. this.control2.disable({ emitEvent: false })

This causes valueChanges to emit next object.

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 2.0.X, 2.1.0

  • Browser: Chrome XX | Firefox XX

  • Language: TypeScript 2.0.3

  • Node (for AoT issues): node --version =

Similar issues

https://github.com/angular/angular/pull/11949

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 30
  • Comments: 26 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@dandouglas It was fixed in 6.0.0 and 5.2.5, you should be fine after updating to at least one of those versions.

Only workaround I found was to set flag before enabling or disabling any field and checking for it on valueChanges. Quite annoying.

Any updates on this? As said above, this causes all valueChanges subscriptions within the disabled form group to emit an event.

I actually got it to work by using .enable({ onlySelf: true, emitEvent: false }) instead of .enable({ emitEvent: false })

I wonder why emitEvent is not passed to the children here in disable() and here in enable()

Please anyone capable to explain to us if this is normal or this is one alledged reason of this issue ? Thanks