Skip to content
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

Long standing problems with template driven forms #51866

Open
kemsky opened this issue Sep 22, 2023 · 5 comments
Open

Long standing problems with template driven forms #51866

kemsky opened this issue Sep 22, 2023 · 5 comments
Labels
area: forms feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Milestone

Comments

@kemsky
Copy link

kemsky commented Sep 22, 2023

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

  • built-in validators like required are still imported with FormsModule
  • ngModel type and type of the corresponding custom value accessor are not checked, effectively [ngModel] has any type and there is zero typecheck, you can pass any property of any type to [ngModel] (e.g Date instead of string) and compiler will be happy.
  • control value accessor does not have access to its validity status, component can only rely on css classes like ng-valid, but it wont work in case you want to show a dropdown which simply does not inherit these classes because it is rendered outside of the component
  • no way to disable built-in css classes like ng-valid
  • validation errors are still not propagated to the parent form
  • [ngModel] still delays write operation one tick compared to any other input property

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

@dylhunn dylhunn added feature Issue that requests a new feature area: forms labels Sep 27, 2023
@ngbot ngbot bot modified the milestone: Backlog Sep 27, 2023
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Sep 28, 2023
@angular-robot
Copy link
Contributor

angular-robot bot commented Sep 28, 2023

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

Copy link
Contributor

angular-robot bot commented Nov 7, 2023

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

Copy link
Contributor

angular-robot bot commented Nov 27, 2023

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Nov 27, 2023
@JeanMeche
Copy link
Member

JeanMeche commented May 11, 2024

Hi, could you give us some more information to see If we can address some of the issues ?

    • Not sure what's the issue here, that's how the whole forms module works, the modules declares several directives (Validators, CVAs etc.)
    • Could you provide a concrete example of what you're trying to do ?
    • Do you have an example what the issue is for this ?

@kemsky
Copy link
Author

kemsky commented May 21, 2024

@JeanMeche,

  1. some validator directives are always imported, like required, if I want to use my custom required validator I have to choose a different name (bad) or have two validators that match the same attribute (also bad).
  2. my issue is about template driven forms, there is no type check at all. It is easy to test, if you add typed ngModel/ngModelChange to all custom accessors in any large app you'll get a ton of errors.
  3. an example would be any form control with drop down/popup like autocomplete that is displayed via cdk overlay, it will not inherit any of the validity styles/classes.
  4. is a consequence of 3., if we had any API to get validity then we don't need built in classes
  5. yes, you can not have this very basic thing, also it makes sense to propagate errors to custom value accessors to be able to show error tooltip for example.
  6. NgModel defers writeValue call to the next tick. Conflicts with OnInit's contract of child components. #13568, there is an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

3 participants