Skip to content

feat(cdk-experimental/selection): add selection state to a list of items #18424

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

Merged
merged 7 commits into from
Feb 20, 2020

Conversation

yifange
Copy link
Contributor

@yifange yifange commented Feb 6, 2020

Add directives and components that make adding selection state to a list of items easier.

  • CdkSelection: container of the selection state. Similar to MatSort
  • CdkSelectionToggle: Applies to individual selectable items to toggle their selection states
  • CdkSelectAll: Similar to CdkSelectionToggle but toggles select-all
  • CdkSelectionColumn: Similar to CdkTextColumn. Adds a column of selection toggles to
    a <cdk-table>
  • CdkRowSelection: Adds aria-selected to the selected table rows.

Will add tests after the implementation is LGTM'd.

Issue #18581

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 6, 2020
@jelbourn jelbourn added G This is is related to a Google internal issue target: development-branch labels Feb 11, 2020
No test coverage so far

(cherry picked from commit 500597f)
Since there is no test added yet.

(cherry picked from commit 5d5327c)
* on them. Because `trackByFn` requires the index of the item to be passed in, the `index` field is
* expected to be set when calling `isSelected`, `select` and `deselect`.
*/
export class SelectionSet<T> implements TrackBySelection<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than introducing a new class, would it be possible to update the existing SelectionModel in cdk/selection to support what this needs?

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 can retrofit the trackByFunction support to SelectionModel, but it doesn't look very clean. Here is a draft: https://gist.github.com/yifange/faab1dcc3dfdb7497c3453bf7ceb7cef
I can polish it and fit it in if you think it is a good idea.

Copy link
Member

Choose a reason for hiding this comment

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

Let's leave this PR as-is for now and revisit this in a follow-up

* on them. Because `trackByFn` requires the index of the item to be passed in, the `index` field is
* expected to be set when calling `isSelected`, `select` and `deselect`.
*/
export class SelectionSet<T> implements TrackBySelection<T> {
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave this PR as-is for now and revisit this in a follow-up

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Feb 18, 2020
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Feb 18, 2020
@yifange
Copy link
Contributor Author

yifange commented Feb 18, 2020

@googlebot I fixed it.

@jelbourn
Copy link
Member

@devversion what's the action on the rollup globals lint check here?

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM, just need to add an entry to CODEOWNERS for the new directory

@jelbourn
Copy link
Member

Ah, looks like there's some actual lint warnings, too

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Feb 20, 2020
@jelbourn jelbourn merged commit b61df23 into angular:cdk-selection Feb 20, 2020
@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 Apr 1, 2020
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 cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants