Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(common): disable keyvalue sorting using null compareFn #57487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

sbarfurth
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

The keyvalue pipe sorts the entries of the input by key. This has been the subject of debate in the past (#42490). The core of the discussions is that it is often desirable (and perhaps expected) that they natural ordering of the input is respected. There are at least two workarounds to restore natural ordering, such as a compareFn that simply returns 1 or a custom pipe. However, both of these require code for pipe consumers to maintain or copy around to many places.

What is the new behavior?

Allowing null as compareFn and treating it as "natural order" is fairly simple to understand, backward compatible and was suggested a few times on #42490 where it seemed to be received well. Using null is also possible in templates without any component code changes.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

n/a

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: common Issues related to APIs in the @angular/common package labels Aug 22, 2024
@ngbot ngbot bot added this to the Backlog milestone Aug 22, 2024
@sbarfurth sbarfurth force-pushed the key-value-null-comparefn branch from 75488e5 to 6352cd2 Compare August 22, 2024 15:39
@sbarfurth
Copy link
Contributor Author

Gentle ping @pkozlowski-opensource

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Oct 16, 2024
@devversion
Copy link
Member

devversion commented Oct 16, 2024

Closing and re-opening since a few CI jobs are missing here (Edit: turned out public API failed)

@devversion devversion closed this Oct 16, 2024
@devversion devversion reopened this Oct 16, 2024
@JeanMeche JeanMeche force-pushed the key-value-null-comparefn branch from 6352cd2 to 3398a93 Compare October 16, 2024 15:12
@devversion devversion added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels Oct 16, 2024
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: public-api
Reviewed-for: fw-common

@devversion devversion added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 16, 2024
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@thePunderWoman thePunderWoman added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 16, 2024
The keyvalue pipe sorts the entries of the input by key. This has been the subject of debate in the past (angular#42490). The core of the discussions is that it is often desirable (and perhaps expected) that they natural ordering of the input is respected. There are at least two workarounds to restore natural ordering, such as a `compareFn` that simply returns `1` or a custom pipe. However, both of these require code for pipe consumers to maintain or  copy around to many places.

Allowing `null` as `compareFn` and treating it as "natural order" is fairly simple to understand, backward compatible and was suggested a few times on angular#42490 where it seemed to be received well. Using `null` is also possible in templates without any component code changes.
@sbarfurth sbarfurth force-pushed the key-value-null-comparefn branch from 3398a93 to 20fbd79 Compare October 16, 2024 15:26
@sbarfurth
Copy link
Contributor Author

sbarfurth commented Oct 16, 2024

I tried rebasing here since running yarn bazel run //packages/common:common_api.accept did not generate any changes. Perhaps it runs through now?

EDIT: Or maybe it did add some updates without me noticing...

@devversion
Copy link
Member

@sbarfurth — I think @JeanMeche pushed to your PR to take care of it, so that's why there is no diff 😄 All good now.

@JeanMeche
Copy link
Member

@sbarfurth I did it for you, we're good to go. The PR is in the merge queue !

@sbarfurth
Copy link
Contributor Author

Ah sorry about that, missed the push. Thanks!

@devversion
Copy link
Member

This PR was merged into the repository by commit 13c1306.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants