Title: KeyValuePipe keeps the previous Map order when only the insertion order changes · Issue #72114 · angular/angular · GitHub
Open Graph Title: KeyValuePipe keeps the previous Map order when only the insertion order changes · Issue #72114 · angular/angular
X Title: KeyValuePipe keeps the previous Map order when only the insertion order changes · Issue #72114 · angular/angular
Description: Hi Angular team 👋 I ran into a small surprise with keyvalue: null. I reversed the entries in a Map and passed the new map to my template. A plain @for picked up the new order, but the row using the pipe stayed in the old order. How to re...
Open Graph Description: Hi Angular team 👋 I ran into a small surprise with keyvalue: null. I reversed the entries in a Map and passed the new map to my template. A plain @for picked up the new order, but the row using the...
X Description: Hi Angular team 👋 I ran into a small surprise with keyvalue: null. I reversed the entries in a Map and passed the new map to my template. A plain @for picked up the new order, but the row using the...
Opengraph URL: https://github.com/angular/angular/issues/72114
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KeyValuePipe keeps the previous Map order when only the insertion order changes","articleBody":"Hi Angular team 👋\n\nI ran into a small surprise with `keyvalue: null`. I reversed the entries in a `Map` and passed the new map to my template. A plain `@for` picked up the new order, but the row using the pipe stayed in the old order.\n\n### How to reproduce\n\nPaste this into `src/main.ts` in an Angular CLI app, run `ng serve`, and click **Reverse** once.\n\n```ts\nimport {KeyValuePipe} from '@angular/common';\nimport {Component, signal} from '@angular/core';\nimport {bootstrapApplication} from '@angular/platform-browser';\n\n@Component({\n selector: 'app-root',\n imports: [KeyValuePipe],\n template: `\n \u003cp>Direct: @for (pair of rows(); track pair[0]) { \u003cspan>{{ pair[0] }}\u003c/span> }\u003c/p>\n \u003cp>Pipe: @for (pair of rows() | keyvalue: null; track pair.key) { \u003cspan>{{ pair.key }}\u003c/span> }\u003c/p>\n \u003cbutton (click)=\"reverse()\">Reverse\u003c/button>\n `,\n})\nclass App {\n readonly rows = signal(new Map([['b', 2], ['a', 1], ['c', 3]]));\n\n reverse() {\n this.rows.update(rows => new Map([...rows].reverse()));\n }\n}\n\nbootstrapApplication(App);\n```\n\n| | Before the click | After the click |\n|---|---|---|\n| Direct iteration | `b a c` | `c a b` |\n| `keyvalue: null` | `b a c` | `b a c` |\n\nI expected both rows to show `c a b`, since passing `null` tells the pipe to use the input’s natural order. If I then change the value of just one entry, the pipe catches up. [KeyValuePipe docs](https://angular.dev/api/common/KeyValuePipe#description)\n\nI also tried calling `transform()` directly. A fresh pipe gives me `c a b` for the reversed map. A pipe that already processed the original map gives me `b a c` for that same reversed map.\n\nI found #71893 while looking into this. That example switches the comparator to `null`. Here it’s `null` from the first render, and only the insertion order changes.\n\nTested with Angular and Angular CLI **22.3.0** (`@angular/common`, AOT), on macOS with Chrome **157.0.8103.79**.","author":{"url":"https://github.com/nagahara-naoki","@type":"Person","name":"nagahara-naoki"},"datePublished":"2026-11-19T13:01:03Z","url":"https://github.com/angular/angular/issues/72114"}
| 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:ed241121-1924-8ae5-a830-8f29f7458f83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C5CC:5D487:E370FB:12E14A3:6B01D60E |
| html-safe-nonce | 30e2a2bdd89484458fdb1f568842d1a699cc0abefd015587dac0cb984fb7755d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUNDOjVENDg3OkUzNzBGQjoxMkUxNEEzOjZCMDFENjBFIiwidmlzaXRvcl9pZCI6IjEwMjgyMjY1OTI3NzU3MjI1MTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cee70d5087a5e7e6ec1d0e02389e938b6b395286defb48f4248b94939e74e208 |
| hovercard-subject-tag | issue:6490158531 |
| 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/72114/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb6dd41bf6d5f5070bd48783e7cffb4054ffac588ddd2f3105c3abfb7db0e0fd/angular/angular/issues/72114 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb6dd41bf6d5f5070bd48783e7cffb4054ffac588ddd2f3105c3abfb7db0e0fd/angular/angular/issues/72114 |
| og:image:alt | Hi Angular team 👋 I ran into a small surprise with keyvalue: null. I reversed the entries in a Map and passed the new map to my template. A plain @for picked up the new order, but the row using the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nagahara-naoki |
| 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