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(chips): Fix chip and chip list selectable #9955

Merged
merged 1 commit into from
Feb 18, 2018

Conversation

tinayuangao
Copy link
Contributor

Fixes #9924

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 14, 2018
testComponent.selectable = false;
fixture.detectChanges();

chips.forEach(chip => {
Copy link
Member

Choose a reason for hiding this comment

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

This one will end up generating a bunch of failure messages if we ever end up breaking the functionality. Something like this might be cleaner:

const chipsValid = chips.every(chip => !chip.selectable && !chip._elementRef.nativeElement.hasAttribute('aria-selected')):

expect(chipsValid).toBe(true);

@@ -274,12 +274,17 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
@Input('aria-orientation') ariaOrientation: 'horizontal' | 'vertical' = 'horizontal';

/**
* Whether or not this chip is selectable. When a chip is not selectable,
* Whether or not this chips are selectable. When a chip is not selectable,
Copy link
Member

Choose a reason for hiding this comment

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

I think the comment still refers to an individual chip, but this is in the chip list.

set selectable(value: boolean) {
this._selectable = coerceBooleanProperty(value);
if (this.chips) {
this.chips.toArray().forEach(chip => chip.chipListSelectable = this._selectable);
Copy link
Member

Choose a reason for hiding this comment

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

IIRC the QueryList already has a forEach method so you shouldn't need the toArray call.

*/
@Input()
get selectable(): boolean { return this._selectable; }
get selectable(): boolean { return this._selectable && this.chipListSelectable; }
Copy link
Member

Choose a reason for hiding this comment

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

Does this work with the OnPush change detection? I think the chip may need a markForCheck somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The selectable on chip list is an @Input().

@tinayuangao
Copy link
Contributor Author

Thanks for review!

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Feb 14, 2018
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 merged commit 949a69b into angular:master Feb 18, 2018
@andrewseguin andrewseguin added the target: minor This PR is targeted for the next minor release label Feb 20, 2018
@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 Sep 8, 2019
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.

Docs for inputs selectable of MatChip and selectable of MatChipList are reverse
5 participants