Title: Select dropdowns with ngValue binding perform far worse than expected · Issue #41330 · angular/angular · GitHub
Open Graph Title: Select dropdowns with ngValue binding perform far worse than expected · Issue #41330 · angular/angular
X Title: Select dropdowns with ngValue binding perform far worse than expected · Issue #41330 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms Is this a regression? Regression from AngularJS. Description I noticed that there was a noticeable delay when populating a select dropdown with several hundred+ ...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms Is this a regression? Regression from AngularJS. Description I noticed that there was a noticeable delay when populating ...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/forms Is this a regression? Regression from AngularJS. Description I noticed that there was a noticeable delay when populating ...
Opengraph URL: https://github.com/angular/angular/issues/41330
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Select dropdowns with ngValue binding perform far worse than expected","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/forms\r\n\r\n### Is this a regression?\r\n\r\nRegression from AngularJS.\r\n\r\n### Description\r\n\r\nI noticed that there was a noticeable delay when populating a select dropdown with several hundred+ items using an ngValue binding, which does not occur with other frameworks (I also tested AngularJS and Svelte). Digging into the Angular code it turns out that the `_compareWith` function in select_control_value_accessor.ts is being called an absurdly high number of times.\r\n\r\nI expected that this function would just be called no more than once for each item in the dropdown (i.e. loop through the options until a match is found). However, it is actually called exponentially more. E.g. for a dropdown with 1000 items and the 500th item bound to the ngModel, the function is called 501,001 times. If there are 3000 items in the dropdown and the 1500th item is selected, the `_compareWith` function is called 1,002,501 times. It gets even worse if an option nearer the end of the list is selected.\r\n\r\n## 🔬 Minimal Reproduction\r\nhttps://stackblitz.com/edit/angular-select-performance?file=src%2Fapp%2Fapp.component.ts\r\n\r\nNote that I added a custom `compareWith` method in this example to log how many times it is called, but the performance is just as bad with the default internal comparison method.\r\n\r\nI think the problem stems from Angular's `SelectControlValueAccessor.writeValue()` method being called over and over for each individual option element that is rendered, rather than once after all the options are rendered.\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:** 11.2.6\r\n\r\n**Anything else relevant?**\r\nThis is especially problematic for our users with slower mobile devices.","author":{"url":"https://github.com/theodorejb","@type":"Person","name":"theodorejb"},"datePublished":"2021-03-23T21:15:27Z","url":"https://github.com/angular/angular/issues/41330"}
| 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:3e4a6528-8a7f-b1d7-c10d-7377d4a89eda |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA8E:FC5BE:17AA0B7:1F655C5:6B01435C |
| html-safe-nonce | f6fcf6d2768b57497e1fc54ee5ee73dcf217e2b568b9cae13983f4d363084899 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQThFOkZDNUJFOjE3QUEwQjc6MUY2NTVDNTo2QjAxNDM1QyIsInZpc2l0b3JfaWQiOiI4NzQyNzQ5MDgzNTEwMzI2MTA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d7f55e88c1f14c1f4579f534cbad62ada238a89f35a4afdfbf555afaed1fc83f |
| hovercard-subject-tag | issue:839129221 |
| 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/41330/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04beaa446809cf5fe23178026f38d5c09c4f473553e72628ddec2560e882ce2b/angular/angular/issues/41330 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04beaa446809cf5fe23178026f38d5c09c4f473553e72628ddec2560e882ce2b/angular/angular/issues/41330 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/forms Is this a regression? Regression from AngularJS. Description I noticed that there was a noticeable delay when populating ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | theodorejb |
| 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