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

fix(cdk-experimental/ui-patterns): add missing event handlers #30786

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

wagnermaciel
Copy link
Contributor

@wagnermaciel wagnermaciel commented Apr 2, 2025

  • Add missing event handlers for alternative multiselection strategy

@wagnermaciel wagnermaciel requested a review from a team as a code owner April 2, 2025 22:25
@wagnermaciel wagnermaciel requested review from crisbeto and mmalerba and removed request for a team April 2, 2025 22:25
@@ -60,7 +60,14 @@ export class ListSelection<T extends ListSelectionItem<V>, V> {

// TODO: Need to discuss when to drop this.
this._anchor();
this.inputs.value.update(values => values.concat(item.value()));

const orderedValues = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this is the behavior we want? It means someone can't build a "pick your top 3" listbox that actually ranks the first, second, third place choices

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, interesting. I'm not sure how important it is to maintain the order of the source options. I believe it was Kristiyan who proposed this change. @crisbeto could you weigh in here?

Copy link
Member

@crisbeto crisbeto Apr 3, 2025

Choose a reason for hiding this comment

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

The context here is that mat-select used to keep the selection order and we had to introduce the sorting, because users found it confusing that going into a multi-select and checking a bunch of stuff could lead to different results each time. There might also be some implications for the data the app submits to the server.

FWIW in mat-select we also have an input that allows users to customize the sorting which we could introduce here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll leave it unsorted for now and wait for feedback from the community on this one. It's easier to add this feature in the future than it would be to remove it. I'm also not convinced we should add a hook for sorting since signals makes it trivial for devs to implement this by just using computed

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think it depends on what you're implementing, for a standard <select multiple> there's no meaning to the order, so it makes sense to order them, but it feels like something that should be up to the developer based on the use case.

@wagnermaciel wagnermaciel added the target: major This PR is targeted for the next major release label Apr 3, 2025
@wagnermaciel wagnermaciel requested a review from mmalerba April 3, 2025 21:37
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM

* Add missing event handlers for alternative multiselection strategy
@wagnermaciel wagnermaciel changed the title fix(cdk-experimental/ui-patterns): listbox selection fixes fix(cdk-experimental/ui-patterns): add missing event handlers Apr 4, 2025
@wagnermaciel wagnermaciel removed the request for review from crisbeto April 4, 2025 15:20
@wagnermaciel wagnermaciel added the action: merge The PR is ready for merge by the caretaker label Apr 4, 2025
@wagnermaciel wagnermaciel merged commit 2e34b20 into angular:main Apr 4, 2025
20 of 22 checks passed
mistrykaran91 pushed a commit to mistrykaran91/components that referenced this pull request Apr 7, 2025
…r#30786)

* Add missing event handlers for alternative multiselection strategy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants