Title: Signal Forms: a FormValueControl stays out of sync when its field is set back to the value it last received · Issue #72065 · angular/angular · GitHub
Open Graph Title: Signal Forms: a FormValueControl stays out of sync when its field is set back to the value it last received · Issue #72065 · angular/angular
X Title: Signal Forms: a FormValueControl stays out of sync when its field is set back to the value it last received · Issue #72065 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description I maintain a component library and moved one of our inputs to a FormValueControl for Angular 22. While testing it, I found a case where the...
Open Graph Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description I maintain a component library and moved one of our inputs to a FormValueControl for Angular 22. Wh...
X Description: Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description I maintain a component library and moved one of our inputs to a FormValueControl for Angular 22. Wh...
Opengraph URL: https://github.com/angular/angular/issues/72065
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Signal Forms: a FormValueControl stays out of sync when its field is set back to the value it last received","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\nI maintain a component library and moved one of our inputs to a `FormValueControl` for Angular 22. While testing it, I found a case where the control and its field stop agreeing on the value, and nothing brings them back together.\n\nIt happens when the control writes its own `value`, and then, before change detection runs, the field is set back to the value the control last received from it. The field ends up with that value, but the control keeps the one it wrote.\n\nHere's a small example: a text input that clears itself on Escape, inside a form that resets on Escape. Both handlers run for the same keypress. It's a complete `src/main.ts`, so it can be pasted into a new Angular project as is.\n\n```ts\nimport { Component, model, signal, viewChild } from '@angular/core';\nimport { FormField, FormValueControl, form } from '@angular/forms/signals';\nimport { bootstrapApplication } from '@angular/platform-browser';\n\n@Component({\n selector: 'app-clearable-input',\n template: `\u003cinput #input [value]=\"value()\" (input)=\"value.set(input.value)\" (keydown.escape)=\"value.set('')\" />`,\n})\nexport class ClearableInput implements FormValueControl\u003cstring> {\n readonly value = model('');\n}\n\n@Component({\n selector: 'app-root',\n imports: [FormField, ClearableInput],\n template: `\n \u003cdiv (keydown.escape)=\"nameForm().reset({ name: 'Ada' })\">\n \u003capp-clearable-input [formField]=\"nameForm.name\" />\n \u003c/div>\n \u003cp>Field value: \"{{ nameForm.name().value() }}\"\u003c/p>\n \u003cp>Control value: \"{{ control().value() }}\"\u003c/p>\n `,\n})\nexport class App {\n protected readonly nameForm = form(signal({ name: 'Ada' }));\n protected readonly control = viewChild.required(ClearableInput);\n}\n\nbootstrapApplication(App);\n```\n\nClick into the input and press Escape without typing first. The field says \"Ada\", but the control, and the input on screen, are empty. Pressing Escape again doesn't help. If you type something before pressing Escape, both end up at \"Ada\" as expected. Setting the field with `nameForm.name().value.set('Ada')` instead of `reset()` goes wrong the same way.\n\nFrom reading the source, I think the cause is in `customControlCreate` in `packages/forms/signals/src/directive/control_custom.ts`. It only pushes `controlValue` into the control when it differs from the value it pushed last time. When the control writes its own model, the `listenToCustomControlModel` callback updates the field but not that remembered value, so setting the old value again looks like no change and is skipped. The CVA path in `control_cva.ts` already handles this: its `registerOnChange` callback updates the remembered value, which came in with #67866 for #67847. I tried the same change in the custom control path locally (setting `bindings['controlValue'] = value` in that callback) and it fixes the example above.\n\nThis looks related to #57124 and #59376, where a `model()` input drifts away from a binding that sets the same value again. There it was described as the contract of a one-way `[x]` binding, but `[formField]` keeps the field and the control in sync in both directions, so here it seems like a bug rather than a design question.\n\n### Please provide a link to a minimal reproduction of the bug\n\nThe example in the description is a complete `src/main.ts`: paste it into a new Angular 22 project (for example `ng new --minimal`) and run `ng serve`.\n\n### Please provide the exception or error you saw\n\n```true\nNo error. The control and its field silently hold different values.\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI : 22.2.7\nAngular : 22.2.6\nNode.js : 24.15.0\nPackage Manager : npm 11.12.1\nOperating System : win32 x64\n\nPackage Installed Version\n@angular/build 22.2.7\n@angular/cli 22.2.7\n@angular/common 22.2.6\n@angular/compiler 22.2.6\n@angular/compiler-cli 22.2.6\n@angular/core 22.2.6\n@angular/forms 22.2.6\n@angular/platform-browser 22.2.6\n@angular/router 22.2.6\nrxjs 7.8.2\ntypescript 6.0.3\n```\n\n### Anything else?\n\nIt also happens on 22.1.0 and 22.3.0-rc.0. The custom control code looks the same in 21.2.x, which is why I answered \"No\" to the regression question.\n\nGitHub suggested #70734, #71127 and #71679 as possible duplicates. I read them, and they're different problems: `updateOn` being ignored under reactive forms, parse errors arriving one change detection late, and `model.subscribe` not firing on form updates.","author":{"url":"https://github.com/StojanovicMilos","@type":"Person","name":"StojanovicMilos"},"datePublished":"2026-11-16T13:43:55Z","url":"https://github.com/angular/angular/issues/72065"}
| 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:bb00ac38-6bf6-2563-c253-396ff53a97c9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8F8:1F927B:104DAFB:158ACA3:6B01DB77 |
| html-safe-nonce | 6a2e7fd0ba1693ec868ed6cb837dee5e358c28a8356e50a64bf73b1fed0365b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEY4OjFGOTI3QjoxMDREQUZCOjE1OEFDQTM6NkIwMURCNzciLCJ2aXNpdG9yX2lkIjoiMTk5NDE1OTU1MzYyMDU5NzYyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd04f39fe0dbeda20f9878c8f0dcd128c13c856dff180f0f3e9587ca111e997c |
| hovercard-subject-tag | issue:6422561829 |
| 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/72065/issue_layout |
| twitter:image | https://opengraph.githubassets.com/98e5fcebb4eca687cf05277219ddeaf0e98024632fbbdbd39dec88215f184bd6/angular/angular/issues/72065 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/98e5fcebb4eca687cf05277219ddeaf0e98024632fbbdbd39dec88215f184bd6/angular/angular/issues/72065 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? forms Is this a regression? No Description I maintain a component library and moved one of our inputs to a FormValueControl for Angular 22. Wh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | StojanovicMilos |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width