-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
Usually, using a min validator (and other similar) in a form schema will apply the min attribute on the native HTML element. So that the browser can enforce it. However when the type of the input is dynamic, then those attribute are never applied.
This prevent us from implementing our own component that would wrap an <input>, even if the type does not actually change during its lifetime. At the minimum, I would expect to be able to set the type attribute dynamically at least one time during construction.
Potential fix
This bug occurs because FormField.elementAcceptsNumericValues (and similar) are set only once, during construction. And it is never updated when the type attribute might change. I would expect that boolean to a signal of boolean, so that attribute might be applied, or removed, whenever the type changes.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/zbvsy93w-dlzorsky?file=src%2Fmain.ts
Please provide the exception or error you saw
The first input correctly restrict age to be greater or equal to 18.
The second input incorrectly does not restrict anything, because the type binding: `<input [type]="myType()">
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 21.1.2
Angular : 21.1.2
Node.js : 20.19.1
Package Manager : npm 10.8.2
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.1.2 │ ^21.1.0-next │
│ @angular/cli │ 21.1.2 │ ^21.1.0-next │
│ @angular/common │ 21.1.2 │ ^21.1.0-next │
│ @angular/compiler │ 21.1.2 │ ^21.1.0-next │
│ @angular/compiler-cli │ 21.1.2 │ ^21.1.0-next │
│ @angular/core │ 21.1.2 │ ^21.1.0-next │
│ @angular/forms │ 21.1.2 │ ^21.1.0-next │
│ @angular/platform-browser │ 21.1.2 │ ^21.1.0-next │
│ @angular/router │ 21.1.2 │ ^21.1.0-next │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.3 │
│ zone.js │ 0.16.0 │ ~0.16.0 │
└───────────────────────────┴───────────────────┴───────────────────┘
Metadata
Metadata
Assignees
Type
Projects
Status