Skip to content

feat(list): Add single select mode. #18126

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 5 commits into from
Jan 15, 2020

Conversation

kseamon
Copy link
Collaborator

@kseamon kseamon commented Jan 7, 2020

Adds support for single selection to mat-selection list, using multiple="false" or [multiple]="false".

Styling is updated to match single-select mat-select panels, including a persistent highlight and hiding the check boxes.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 7, 2020
@kseamon kseamon force-pushed the single-select-list branch from dfe69da to b7709be Compare January 7, 2020 22:33
@@ -33,6 +33,10 @@
background: mat-color($background, 'hover');
}
}

.mat-selection-list-single-select .mat-list-option.mat-selected {
background: mat-color($background, hover, 0.12);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this make it difficult to distinguish between selected and hovered options?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the same style used in MatSelect.

It actually is darker than the hover color, despite how the line reads.

single-select-hover

set multiple(value: boolean) {
const newValue = coerceBooleanProperty(value);

if (newValue !== this._multiple) {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about only doing this check in dev mode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -108,6 +109,7 @@ export class MatSelectionListChange {
// be placed inside a parent that has one of the other colors with a higher specificity.
'[class.mat-accent]': 'color !== "primary" && color !== "warn"',
'[class.mat-warn]': 'color === "warn"',
'[class.mat-single-selected]': 'selected && !selectionList.multiple',
Copy link
Member

Choose a reason for hiding this comment

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

We typically include the component name in the class: .mat-list-single-item-selected (except for the theme classes which are universal)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@kseamon kseamon force-pushed the single-select-list branch from 2948622 to e4c00ad Compare January 10, 2020 18:39
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

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Jan 11, 2020
@jelbourn jelbourn added this to the 9.1.0 milestone Jan 11, 2020
@andrewseguin andrewseguin merged commit 3b242f0 into angular:master Jan 15, 2020
yifange pushed a commit to yifange/components that referenced this pull request Jan 30, 2020
* feat(list): Add single select mode.

* review changes

* lint

* review changes

* fix tests
@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 Feb 15, 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 target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants