Skip to content

Commit

Permalink
fix(material/chips): allow attribute selectors for chips (#26683)
Browse files Browse the repository at this point in the history
Updates the selector for chips to allow attributes like in the legacy chips.

Fixes #26677.

(cherry picked from commit f7a5bcb)
  • Loading branch information
crisbeto committed Feb 23, 2023
1 parent 79f15dc commit 9a57674
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions guides/v15-mdc-migration.md
Expand Up @@ -271,6 +271,8 @@ DOM and CSS of the components, you may need to tweak some of your application's

### Chips

* Chips used to be directives, but they're now components. This means that they can't be applied to
other components anymore.
* The chips component has been split into multiple variants corresponding with more appropriate
interaction patterns for accessibility. The original `mat-chip-list` used `role="listbox"`, but
this interaction pattern is not suited for all use-cases. The new chips have:
Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chip-option.ts
Expand Up @@ -39,7 +39,7 @@ export class MatChipSelectionChange {
* user cannot click disabled chips.
*/
@Component({
selector: 'mat-basic-chip-option, mat-chip-option',
selector: 'mat-basic-chip-option, [mat-basic-chip-option], mat-chip-option, [mat-chip-option]',
templateUrl: 'chip-option.html',
styleUrls: ['chip.css'],
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],
Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chip-row.ts
Expand Up @@ -44,7 +44,7 @@ export interface MatChipEditedEvent extends MatChipEvent {
* the matChipInputFor directive.
*/
@Component({
selector: 'mat-chip-row, mat-basic-chip-row',
selector: 'mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]',
templateUrl: 'chip-row.html',
styleUrls: ['chip.css'],
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],
Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chip.ts
Expand Up @@ -80,7 +80,7 @@ const _MatChipMixinBase = mixinTabIndex(
* Extended by MatChipOption and MatChipRow for different interaction patterns.
*/
@Component({
selector: 'mat-basic-chip, mat-chip',
selector: 'mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]',
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],
exportAs: 'matChip',
templateUrl: 'chip.html',
Expand Down
6 changes: 3 additions & 3 deletions tools/public_api_guard/material/chips.md
Expand Up @@ -114,7 +114,7 @@ export class MatChip extends _MatChipMixinBase implements AfterViewInit, CanColo
// (undocumented)
protected _value: any;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, mat-chip", ["matChip"], { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "role": "role"; "id": "id"; "ariaLabel": "aria-label"; "ariaDescription": "aria-description"; "value": "value"; "removable": "removable"; "highlighted": "highlighted"; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "trailingIcon", "removeIcon"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatChip, "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", ["matChip"], { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "role": "role"; "id": "id"; "ariaLabel": "aria-label"; "ariaDescription": "aria-description"; "value": "value"; "removable": "removable"; "highlighted": "highlighted"; }, { "removed": "removed"; "destroyed": "destroyed"; }, ["leadingIcon", "trailingIcon", "removeIcon"], ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatChip, [null, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ export class MatChipOption extends MatChip implements OnInit {
_setSelectedState(isSelected: boolean, isUserInput: boolean, emitEvent: boolean): void;
toggleSelected(isUserInput?: boolean): boolean;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatChipOption, "mat-basic-chip-option, mat-chip-option", never, { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "selectable": "selectable"; "selected": "selected"; }, { "selectionChange": "selectionChange"; }, never, ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatChipOption, "mat-basic-chip-option, [mat-basic-chip-option], mat-chip-option, [mat-chip-option]", never, { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "selectable": "selectable"; "selected": "selected"; }, { "selectionChange": "selectionChange"; }, never, ["mat-chip-avatar, [matChipAvatar]", "*", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatChipOption, never>;
}
Expand Down Expand Up @@ -399,7 +399,7 @@ export class MatChipRow extends MatChip implements AfterViewInit {
_isEditing: boolean;
_mousedown(event: MouseEvent): void;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatChipRow, "mat-chip-row, mat-basic-chip-row", never, { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "editable": "editable"; }, { "edited": "edited"; }, ["contentEditInput"], ["mat-chip-avatar, [matChipAvatar]", "*", "[matChipEditInput]", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatChipRow, "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", never, { "color": "color"; "disabled": "disabled"; "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "editable": "editable"; }, { "edited": "edited"; }, ["contentEditInput"], ["mat-chip-avatar, [matChipAvatar]", "*", "[matChipEditInput]", "mat-chip-trailing-icon,[matChipRemove],[matChipTrailingIcon]"], false, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatChipRow, [null, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
}
Expand Down

0 comments on commit 9a57674

Please sign in to comment.