Skip to content
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

Subject: Feature Request: Restore Reset Functionality for contentChildren Signal API #55823

Closed
ChristianKlima opened this issue May 16, 2024 · 3 comments
Labels
area: core Issues related to the framework runtime core: queries cross-cutting: signals needs: clarification This issue needs additional clarification from the reporter before the team can investigate.
Milestone

Comments

@ChristianKlima
Copy link

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Dear Angular Team,

I hope this message finds you well. I'm reaching out to request a feature enhancement regarding the recent changes in the Angular framework.

Previously, the @ContentChildren decorator provided a QueryList which included a useful reset() function. This function allowed developers to modify the order of elements within the QueryList. However, with the introduction of the new Signal API contentChildren(), the returned result is now a read-only array, devoid of the reset() functionality.

I understand that the Signal API offers advantages, but the absence of the reset() function has caused inconvenience in scenarios where dynamic manipulation of the query list order is required.

Hence, I kindly request considering the restoration of the reset() functionality for the contentChildren() Signal API in future Angular releases. This feature would greatly enhance the flexibility and usability of the framework for developers.

Thank you for considering my request. I appreciate your ongoing efforts to improve Angular and look forward to seeing its continued evolution.

Best regards,

Christian

Proposed solution

Possibility to change order of query-result

Alternatives considered


@JoostK
Copy link
Member

JoostK commented May 16, 2024

The signal APIs reflect the factual query state and is not meant to be mutated. If you need to influence their ordering, you'll have to derive a second state value from the query signal.

QueryList.reset itself wasn't really intended to public either, it is an implementation detail that that ended up being public.

@JoostK JoostK added area: core Issues related to the framework runtime core: queries cross-cutting: signals labels May 16, 2024
@ngbot ngbot bot added this to the needsTriage milestone May 16, 2024
@pkozlowski-opensource
Copy link
Member

I would very much like to echo @JoostK message - the QueryList.reset ended up in the public API by an unfortunate accident - it never meant to be public / used by application developers.

As @JoostK mentioned one way of going about re-ordering of results would be to use a computed signal. Having said this I'm curious about the exact use-case that you are trying to address - would you mind share more info on why the re-ordering is needed?

@pkozlowski-opensource pkozlowski-opensource added the needs: clarification This issue needs additional clarification from the reporter before the team can investigate. label May 16, 2024
@ChristianKlima
Copy link
Author

Thank you for the response, I understand. The use case was a Carousel component where the position of the contents needs to be swapped, all without triggering the ChangeDetection. I believe I might find an alternative solution for this. I just wanted to inquire if there was a replacement for the reset function. Since it's not intended to be public anyway, I'll have to find a different approach. Many thanks, and greetings to the Angular Team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime core: queries cross-cutting: signals needs: clarification This issue needs additional clarification from the reporter before the team can investigate.
Projects
None yet
Development

No branches or pull requests

3 participants