s-libs icon indicating copy to clipboard operation
s-libs copied to clipboard

[ng-core] Feature request: Sync validation errors, touched, and dirty status

Open ersimont opened this issue 4 years ago • 3 comments

It is possible to sync these things 2-ways between the outer and inner form controls. See the example from @DmitryEfimenko at https://github.com/DmitryEfimenko/s-libs-superclass

ersimont avatar Apr 21 '21 01:04 ersimont

Update, after much debate, I will put this on hold until after angular 12 is out. Because I don't think I would get the full functionality implemented in time, and there are some quicker wins I could get out the door sooner.

The full list of features that should go together (in draft form, after some brainstorming):

  • pending

  • validation errors

    • valid invalid hasError getError
  • touched & untouched

  • dirty & pristine

  • disabled & enabled

  • status

    • status changes
  • name

  • path?

The general idea is to fully synchronize the outer NgControl with the inner one, IF that outer control exists. (If it does not exist, no problem, just keep today's behavior without these extra features.)

ersimont avatar Apr 28 '21 00:04 ersimont

It looks like support is missing for InjectFlags.Optional, as used at https://github.com/DmitryEfimenko/s-libs-superclass/blob/main/src/app/simple-autocomplete/wrapped-form-control-superclass.ts#L186.

It looks like support may still land in v13? https://github.com/angular/angular/pull/41592 Though it seems like 13 should be fairly locked by now ...

ersimont avatar Oct 06 '21 01:10 ersimont

Yeah, this was a while ago. I almost don't remember what was the culprit. Hopefully Angular team can get this PR in for the v13.

DmitryEfimenko avatar Oct 06 '21 02:10 DmitryEfimenko