Title: Signal Forms Optional Fields - Nullability · Issue #65454 · angular/angular · GitHub
Open Graph Title: Signal Forms Optional Fields - Nullability · Issue #65454 · angular/angular
X Title: Signal Forms Optional Fields - Nullability · Issue #65454 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description Signal Form Models cannot contain optional fields or fields with type null or undefined. However I'd suggest we should be able to be expres...
Open Graph Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description Signal Form Models cannot contain optional fields or fields with type null or undefined. However I'...
X Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description Signal Form Models cannot contain optional fields or fields with type null or undefined. However I&...
Opengraph URL: https://github.com/angular/angular/issues/65454
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Signal Forms Optional Fields - Nullability","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nforms\n\n### Is this a regression?\n\nNo\n\n### Description\n\nSignal Form Models cannot contain optional fields or fields with type null or undefined. However I'd suggest we should be able to be express optional fields with nullable types. The current approach causes issues with number values and input type=\"number\" in particular.\n\n\n```typescript\nmodel = signal\u003c{\n count: number | null\n}>({\n count: null\n});\ncountForm = form(this.model);\n```\nError on [field] binding:\n\n\u003cimg width=\"948\" height=\"342\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/f98f66f1-968f-4aeb-829f-496f41baa130\" />\n\nIf initialized with a number, it will be set to NaN when cleared:\n```typescript\nmodel = signal\u003c{\n count: number\n }>({\n count: 0\n });\ncountForm = form(this.model);\n```\n\n\u003cimg width=\"257\" height=\"87\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/7962f66e-6319-4978-b397-147e948e8dd0\" />\n\nIf initialized with empty string (not a desired type union of number | string) the editing the input will now always update model with the string value of the input\n\n```typescript\nmodel = signal\u003c{\n count: number | string\n }>({\n count: ''\n });\ncountForm = form(this.model);\n```\n\n\u003cimg width=\"742\" height=\"190\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/b8182873-9ba6-4a3e-ba4d-7a793d7e4887\" />\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://stackblitz.com/edit/stackblitz-starters-gdr1gfhv?file=src%2Fmain.ts\n\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nStackblitz: https://stackblitz.com/edit/stackblitz-starters-gdr1gfhv?file=src%2Fmain.ts\n\n┌───────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/animations │ 21.0.0 │ ^21.0.0 │\n│ @angular/build │ 21.0.0 │ ^21.0.0 │\n│ @angular/cli │ 21.0.0 │ ^21.0.0 │\n│ @angular/common │ 21.0.0 │ ^21.0.0 │\n│ @angular/compiler │ 21.0.0 │ ^21.0.0 │\n│ @angular/compiler-cli │ 21.0.0 │ ^21.0.0 │\n│ @angular/core │ 21.0.0 │ ^21.0.0 │\n│ @angular/forms │ 21.0.0 │ ^21.0.0 │\n│ @angular/platform-browser │ 21.0.0 │ ^21.0.0 │\n│ @angular/router │ 21.0.0 │ ^21.0.0 │\n│ rxjs │ 7.8.2 │ ^7.8.1 │\n│ typescript │ 5.9.3 │ ^5.9.3 │\n│ zone.js │ 0.15.0 │ ~0.15.0 │\n```\n\n### Anything else?\n\nIn the stackblitz repro I also provided ngModel and FormControl comparisons. Both write back null when clearing the respective input.","author":{"url":"https://github.com/raven-dever","@type":"Person","name":"raven-dever"},"datePublished":"2025-11-21T02:20:23Z","url":"https://github.com/angular/angular/issues/65454"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1420c7e7-acf3-fcf4-f8f6-07373b4751bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B450:39FDE1:B0373C:DCFBB4:6B02220D |
| html-safe-nonce | a29d6c9ff5ddfeb0b0525df5fd9c6d6c30b4e9825a28b868eb633ba63e8bf569 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDUwOjM5RkRFMTpCMDM3M0M6RENGQkI0OjZCMDIyMjBEIiwidmlzaXRvcl9pZCI6IjQ0NTA1NTE0NDAxMjA4ODE2NzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b2300377ee9ee946d15d1f42ba48021f59ea91e23ef77669b774fb254be727e4 |
| hovercard-subject-tag | issue:3649932394 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/65454/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7cf1a66ac1abdfa71420cc249556809aaeafc26ec70a422e44c1b5f1ca09bce4/angular/angular/issues/65454 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7cf1a66ac1abdfa71420cc249556809aaeafc26ec70a422e44c1b5f1ca09bce4/angular/angular/issues/65454 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description Signal Form Models cannot contain optional fields or fields with type null or undefined. However I'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | raven-dever |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width