René's URL Explorer Experiment


Title: [BUG]: Component implementing ControlValueAccessor used inside ngFor loses data · Issue #37920 · angular/angular · GitHub

Open Graph Title: [BUG]: Component implementing ControlValueAccessor used inside ngFor loses data · Issue #37920 · angular/angular

X Title: [BUG]: Component implementing ControlValueAccessor used inside ngFor loses data · Issue #37920 · angular/angular

Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms. Angular 8+ (I haven't tested in versions before v8.0). Is this a regression? No, this bug happens since v8.0, and remains in v10. Description This bug occurs wh...

Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms. Angular 8+ (I haven't tested in versions before v8.0). Is this a regression? No, this bug happens since v8.0, and remain...

X Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms. Angular 8+ (I haven't tested in versions before v8.0). Is this a regression? No, this bug happens since v8.0, and re...

Opengraph URL: https://github.com/angular/angular/issues/37920

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG]: Component implementing ControlValueAccessor used inside ngFor loses data","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/forms.\r\nAngular 8+ (I haven't tested in versions before v8.0).\r\n\r\n### Is this a regression?\r\n\r\nNo, this bug happens since v8.0, and remains in v10.\r\n\r\n### Description\r\n\r\nThis bug occurs when you have a component that implements ControlValueAccessor and it's used inside an *ngFor.\r\nDependending on the order that you add and remove the elements, some data are lost.\r\n```typescript\r\nimport { Component, VERSION } from '@angular/core';\r\n\r\n@Component({\r\n  selector: 'my-app',\r\n  template: `\r\n  \u003cform>\r\n  \u003cdiv *ngFor=\"let data of dataList; index as i;\">\r\n    \u003clabel for=\"inputDescription{{i}}\">Description\u003c/label>\r\n    \u003csample-input\r\n      [(ngModel)]=\"data.description\"\r\n      [ngModelOptions]=\"{ standalone: true }\"\r\n      [index]=\"i\">\u003c/sample-input>\r\n    \u003cbutton type=\"button\" (click)=\"removeData(i)\">Remove\u003c/button>\r\n  \u003c/div>\r\n  \u003cdiv>\r\n    \u003cbutton type=\"button\" (click)=\"addData()\">Add\u003c/button>\r\n  \u003c/div>\r\n  \u003cdiv>\r\n    \u003cpre>{{ dataList | json }}\u003c/pre>\r\n  \u003c/div>\r\n\u003c/form>\r\n  `\r\n})\r\nexport class AppComponent  {\r\n  name = 'Angular ' + VERSION.major;\r\n\r\n  dataList = [];\r\n\r\n  addData() {\r\n    this.dataList.push({ description: '' });\r\n  }\r\n\r\n  removeData(index) {\r\n    this.dataList.splice(index, 1);\r\n  }\r\n}\r\n```\r\n```typescript\r\nimport { Component, StaticProvider, forwardRef, Input } from '@angular/core';\r\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR, NgForm, ControlContainer } from '@angular/forms';\r\n\r\nexport const SAMPLE_INPUT_VALUE_ACCESSOR: StaticProvider = {\r\n  provide: NG_VALUE_ACCESSOR,\r\n  useExisting: forwardRef(() => SampleInputComponent),\r\n  multi: true\r\n};\r\n\r\n@Component({\r\n  selector: 'sample-input',\r\n  template: `\u003cinput type=\"text\" id=\"inputDescription{{ index }}\" [(ngModel)]=\"value\" name=\"inputDescription{{ index }}\" />`,\r\n  providers: [SAMPLE_INPUT_VALUE_ACCESSOR],\r\n  viewProviders: [ { provide: ControlContainer, useExisting: NgForm } ]\r\n})\r\nexport class SampleInputComponent implements ControlValueAccessor {\r\n\r\n  @Input() index;\r\n\r\n  private onChange: (_: any) => { };\r\n  private onTouched: () => { };\r\n  private _value: any;\r\n\r\n  public get value() {\r\n    return this._value;\r\n  }\r\n\r\n  public set value(value: any) {\r\n    this._value = value;\r\n    this.onChange(value);\r\n  }\r\n\r\n  writeValue(obj: any): void {\r\n    this._value = obj;\r\n  }\r\n\r\n  registerOnChange(fn: any): void {\r\n    this.onChange = fn;\r\n  }\r\n\r\n  registerOnTouched(fn: any): void {\r\n    this.onTouched = fn;\r\n  }\r\n\r\n  setDisabledState(isDisabled: boolean): void {\r\n\r\n  }\r\n}\r\n```\r\n\r\n## 🔬 Minimal Reproduction\r\n1 - Insert 4 elements (with value):\r\n![image](https://user-images.githubusercontent.com/6237931/86503718-f6acab80-bd86-11ea-900c-aaa925555266.png)\r\n2 - Then remove the first element:\r\n![image](https://user-images.githubusercontent.com/6237931/86503725-088e4e80-bd87-11ea-9c04-413698c23418.png)\r\n3 - Insert new element:\r\n![image](https://user-images.githubusercontent.com/6237931/86503741-3bd0dd80-bd87-11ea-9cef-0f753db408cb.png)\r\n**Problem: value 4 is gone**\r\n\r\nExample: [https://stackblitz.com/edit/angular-ivy-uqpssy](https://stackblitz.com/edit/angular-ivy-uqpssy)\r\n\r\n## 🔥 Exception or Error\r\nNone\r\n\r\n\r\n## 🌍  Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>@angular/animations10.0.1\r\n@angular/common10.0.1\r\n@angular/compiler10.0.1\r\n@angular/core10.0.1\r\n@angular/forms10.0.1\r\n@angular/platform-browser10.0.1\r\n@angular/platform-browser-dynamic10.0.1\r\n@angular/router10.0.1\r\nrxjs6.5.5\r\ntslib2.0.0\r\nzone.js\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\nChrome version: 83.0.4103.116 - 64 bits","author":{"url":"https://github.com/rafaelmfonseca","@type":"Person","name":"rafaelmfonseca"},"datePublished":"2020-07-04T02:53:17Z","url":"https://github.com/angular/angular/issues/37920"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3b93d316-480b-9680-9c0c-1a9f949d93a7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEA0E:317608:1BF6F76:236965E:6B015174
html-safe-nonce09db141cb493a46e122981f2858c1fce189aa80adeb3bb8d3c1a4f0db52096b6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTBFOjMxNzYwODoxQkY2Rjc2OjIzNjk2NUU6NkIwMTUxNzQiLCJ2aXNpdG9yX2lkIjoiMzU5NjE3NDMzMjAyOTY1MzM2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac94b68e961a3344aa353babce9fbfbb3d0e1234adf1e093c5eb58fd07c5d10720
hovercard-subject-tagissue:650815502
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/37920/issue_layout
twitter:imagehttps://opengraph.githubassets.com/70d9046ff579f72c91c3c55c4bf48a18604aefc1084961bcf29a3492fb470f3c/angular/angular/issues/37920
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/70d9046ff579f72c91c3c55c4bf48a18604aefc1084961bcf29a3492fb470f3c/angular/angular/issues/37920
og:image:alt🐞 bug report Affected Package The issue is caused by package @angular/forms. Angular 8+ (I haven't tested in versions before v8.0). Is this a regression? No, this bug happens since v8.0, and remain...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerafaelmfonseca
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/37920#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F37920
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F37920
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/37920
Reloadhttps://github.com/angular/angular/issues/37920
Reloadhttps://github.com/angular/angular/issues/37920
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues836 (836)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/37920
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/37920
[BUG]: Component implementing ControlValueAccessor used inside ngFor loses datahttps://github.com/angular/angular/issues/37920#top
https://github.com/crisbeto
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P3%22
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
forms: ControlValueAccessorhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22forms%3A%20ControlValueAccessor%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/rafaelmfonseca
rafaelmfonsecahttps://github.com/rafaelmfonseca
on Jul 4, 2020https://github.com/angular/angular/issues/37920#issue-650815502
https://user-images.githubusercontent.com/6237931/86503718-f6acab80-bd86-11ea-900c-aaa925555266.png
https://user-images.githubusercontent.com/6237931/86503725-088e4e80-bd87-11ea-9c04-413698c23418.png
https://user-images.githubusercontent.com/6237931/86503741-3bd0dd80-bd87-11ea-9cef-0f753db408cb.png
https://stackblitz.com/edit/angular-ivy-uqpssyhttps://stackblitz.com/edit/angular-ivy-uqpssy
AndrewKushnirhttps://github.com/AndrewKushnir
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
on Jul 6, 2020https://github.com/angular/angular/issues/37920#event-3514350830
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Jul 6, 2020https://github.com/angular/angular/issues/37920#event-3514350887
AndrewKushnirhttps://github.com/AndrewKushnir
forms: ControlValueAccessorhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22forms%3A%20ControlValueAccessor%22
on Jul 6, 2020https://github.com/angular/angular/issues/37920#event-3514351058
AndrewKushnirhttps://github.com/AndrewKushnir
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
on Sep 4, 2020https://github.com/angular/angular/issues/37920#event-3727343469
https://github.com/AndrewKushnir
AndrewKushnirhttps://github.com/AndrewKushnir
on Sep 4, 2020https://github.com/angular/angular/issues/37920#issuecomment-686837473
@rafaelmfonsecahttps://github.com/rafaelmfonseca
#38465https://github.com/angular/angular/issues/38465
it's shown in the docshttps://angular.io/api/common/NgForOf#description
AndrewKushnirhttps://github.com/AndrewKushnir
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P3%22
on Oct 23, 2020https://github.com/angular/angular/issues/37920#event-3911865014
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Oct 23, 2020https://github.com/angular/angular/issues/37920#event-3911865043
crisbetohttps://github.com/crisbeto
on Jan 16, 2021https://github.com/angular/angular/issues/37920#event-4213986400
crisbetohttps://github.com/crisbeto
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
on Jan 16, 2021https://github.com/angular/angular/issues/37920#event-4213986450
crisbetohttps://github.com/crisbeto
on Feb 4, 2022https://github.com/angular/angular/issues/37920#event-6009980744
fix(forms): incorrectly keeping track of ngModel with ngFor inside a …https://github.com/crisbeto/angular/commit/59887c27f4b4bb12d76d22201c57c4a8964ee0a4
https://docs.github.com/articles/closing-issues-via-commit-messages
59887c2https://github.com/crisbeto/angular/commit/59887c27f4b4bb12d76d22201c57c4a8964ee0a4
dylhunnhttps://github.com/dylhunn
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
ebf2fc5https://github.com/angular/angular/commit/ebf2fc5224c9debfd839087c9d1d21fb49577d37
on Feb 7, 2022https://github.com/angular/angular/issues/37920#event-6022358297
dylhunnhttps://github.com/dylhunn
on Feb 7, 2022https://github.com/angular/angular/issues/37920#event-6022358626
fix(forms): incorrectly keeping track of ngModel with ngFor inside a …https://github.com/angular/angular/commit/b75e90f8096394eeef85fa7e667889b7b59a35ed
https://docs.github.com/articles/closing-issues-via-commit-messages
b75e90fhttps://github.com/angular/angular/commit/b75e90f8096394eeef85fa7e667889b7b59a35ed
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Mar 10, 2022https://github.com/angular/angular/issues/37920#issuecomment-1064230489
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Mar 10, 2022https://github.com/angular/angular/issues/37920#event-6218966762
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/37920
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/37920
crisbetohttps://github.com/crisbeto
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P3%22
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
forms: ControlValueAccessorhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22forms%3A%20ControlValueAccessor%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.