Title: KeyValuePipe keeps the previous sort order when compareFn changes to null · Issue #71893 · angular/angular · GitHub
Open Graph Title: KeyValuePipe keeps the previous sort order when compareFn changes to null · Issue #71893 · angular/angular
X Title: KeyValuePipe keeps the previous sort order when compareFn changes to null · Issue #71893 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? common Is this a regression? Yes Description Description KeyValuePipe docs say "Passing null as the compareFn will use natural ordering of the input." When the comparator switches fr...
Open Graph Description: Which @angular/* package(s) are the source of the bug? common Is this a regression? Yes Description Description KeyValuePipe docs say "Passing null as the compareFn will use natural ordering of the...
X Description: Which @angular/* package(s) are the source of the bug? common Is this a regression? Yes Description Description KeyValuePipe docs say "Passing null as the compareFn will use natural ordering o...
Opengraph URL: https://github.com/angular/angular/issues/71893
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KeyValuePipe keeps the previous sort order when compareFn changes to null","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncommon\n\n### Is this a regression?\n\nYes\n\n### Description\n\n### Description\n`KeyValuePipe` docs say \"Passing `null` as the compareFn will use natural ordering of the input.\"\nWhen the comparator switches from a function to `null` and the input object doesn't change, the\npipe keeps returning the previously sorted array instead of the natural order.\n\n```ts\n@Component({\n template: `@for (e of obj | keyvalue: (sorted() ? byKey : null); track e.key) { {{ e.key }} }`,\n})\nexport class App {\n obj = {b: 1, a: 2};\n sorted = signal(true);\n byKey = (x: KeyValue\u003cstring, number>, y: KeyValue\u003cstring, number>) => x.key.localeCompare(y.key);\n}\n```\n\n1. Initially renders `a b` (sorted).\n2. `sorted.set(false)` → still renders `a b`. Expected `b a` (natural order).\n\nIn `keyvalue_pipe.ts`, a comparator change re-sorts only when the new `compareFn` is truthy, and\n`keyValues` is rebuilt only when the input itself changed, so the previous sort is never undone.\n\nI'd be happy to send a PR with a spec if this should be fixed.","author":{"url":"https://github.com/MeAkib","@type":"Person","name":"MeAkib"},"datePublished":"2026-11-09T18:13:38Z","url":"https://github.com/angular/angular/issues/71893"}
| 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:9a4e4ffc-d852-a253-1fe5-e06abc37d2a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB92:EA06E:39E7F15:49984F7:6B01E14F |
| html-safe-nonce | 03c7894293c2e46d49aee19d6faa3104d3e757bed16640e6166e41915caac5ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjkyOkVBMDZFOjM5RTdGMTU6NDk5ODRGNzo2QjAxRTE0RiIsInZpc2l0b3JfaWQiOiI4NzAwMzI3OTQ0OTMwODQ1MDA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 383413352cbf168204989d660e9ac41c0144a244827ad9b5402cb2670328d826 |
| hovercard-subject-tag | issue:6291942256 |
| 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/71893/issue_layout |
| twitter:image | https://opengraph.githubassets.com/71ba721aabe0dbc38bb09bb3d87ec12658ae271a4bb3a8e2e46a9b1c064ecebd/angular/angular/issues/71893 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/71ba721aabe0dbc38bb09bb3d87ec12658ae271a4bb3a8e2e46a9b1c064ecebd/angular/angular/issues/71893 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? common Is this a regression? Yes Description Description KeyValuePipe docs say "Passing null as the compareFn will use natural ordering of the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MeAkib |
| 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