-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
1587bf5
to
5d5327c
Compare
5d5327c
to
8b279b5
Compare
* 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> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
...ts-examples/cdk-experimental/selection/cdk-selection-column/cdk-selection-column-example.css
Outdated
Show resolved
Hide resolved
* 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> { |
There was a problem hiding this comment.
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
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. ℹ️ Googlers: Go here for more info. |
5ebb693
to
2fefe74
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@googlebot I fixed it. |
@devversion what's the action on the rollup globals lint check here? |
There was a problem hiding this 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
Ah, looks like there's some actual lint warnings, too |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Add directives and components that make adding selection state to a list of items easier.
CdkSelection
: container of the selection state. Similar toMatSort
CdkSelectionToggle
: Applies to individual selectable items to toggle their selection statesCdkSelectAll
: Similar toCdkSelectionToggle
but toggles select-allCdkSelectionColumn
: Similar toCdkTextColumn
. Adds a column of selection toggles toa
<cdk-table>
CdkRowSelection
: Addsaria-selected
to the selected table rows.Will add tests after the implementation is LGTM'd.
Issue #18581