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

[FEATURE] - "Select All" option with toggle to clear #145

Closed
allensutton opened this issue May 8, 2019 · 9 comments · Fixed by #166 or #167
Closed

[FEATURE] - "Select All" option with toggle to clear #145

allensutton opened this issue May 8, 2019 · 9 comments · Fixed by #166 or #167
Labels
feature New feature or request

Comments

@allensutton
Copy link

Is your feature request related to a problem? Please describe.

If there are a lot of options, it is a bit tedious to select them one by one if the user merely wants to select all of them. In addition, it would be tedious to deselect all of the selected items.
Describe the solution you'd like

Please add a way to add functionality for a "Select All" option that would be clicked to select every item in the list, and when the user clicks on the Select All option again, it will clear the selections that have been made. It would also be good if selecting all items manually automatically checked the "Select All" option (due to all items being selected).
Describe alternatives you've considered

mat-select-autocomplete-formcontrol does this, however your ngx-mat-select-search solution looks better visually. I have attempted to do this myself, but I can only get "Select All" to work, but it takes a few seconds to work. I cannot get Clear All to work, however.
Additional context

This is a similar implementation: https://stackblitz.com/edit/mat-select-autocomplete-formcontrol

@macjohnny
Copy link
Member

@allensutton sounds like a good idea.
so you suggest to implement a checkbox next to the input field, similar to https://stackblitz.com/edit/mat-select-autocomplete-formcontrol
image
?

would you like to start working on this? I can help you if you need assistance, just send me a link to your code.

@macjohnny macjohnny added the feature New feature or request label May 8, 2019
@allensutton
Copy link
Author

Sure, I can give it a shot. I have a previous stackblitz here:

https://stackblitz.com/edit/github-mfmoas

However, I think I accidentally overwrote the concept I had going, so I'll see if I can get back to where I was where I had the "select all" working but not the "clear all" part.

@allensutton
Copy link
Author

I just found out that Material has added this:
https://material.angular.io/components/list/api#MatSelectionList

It has selectAll() and deselectAll() methods

@macjohnny
Copy link
Member

@allensutton can we close this issue?

@blazewalker59
Copy link
Contributor

blazewalker59 commented Jul 29, 2019

@macjohnny this feature would be a welcome one. The selectAll(), deselectAll() methods that @allensutton pointed out in his last comment appear to only be for the mat-selection-list component and not the mat-select component. ideally, the implementation would function similar to the the example you mentioned above ( https://stackblitz.com/edit/mat-select-autocomplete-formcontrol ). where the checkbox is in the search box and it will select the results that are returned by the filter

*edit - I've created a stackblitz roughly creating the functionality. there is a checkbox added which emits a boolean whether to select all, that the parent component then uses to patch the form value with the filtered selection.

https://stackblitz.com/edit/mat-select-search-with-select-all

@macjohnny
Copy link
Member

Would you like to file a PR for this?

@blazewalker59
Copy link
Contributor

Sure thing, I've never worked on a public repo before. Is there anything in particular needed for approval? I've got a working copy now, just finishing up some styling.

@macjohnny
Copy link
Member

Just give it a try, we will have a look at it in the code review to see what could be changed.

@macjohnny
Copy link
Member

this is released in version 1.8.0, thanks to @blazewalker59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
3 participants