Skip to content

Commit 9a57674

Browse files
committed
fix(material/chips): allow attribute selectors for chips (#26683)
Updates the selector for chips to allow attributes like in the legacy chips. Fixes #26677. (cherry picked from commit f7a5bcb)
1 parent 79f15dc commit 9a57674

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

guides/v15-mdc-migration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ DOM and CSS of the components, you may need to tweak some of your application's
271271

272272
### Chips
273273

274+
* Chips used to be directives, but they're now components. This means that they can't be applied to
275+
other components anymore.
274276
* The chips component has been split into multiple variants corresponding with more appropriate
275277
interaction patterns for accessibility. The original `mat-chip-list` used `role="listbox"`, but
276278
this interaction pattern is not suited for all use-cases. The new chips have:

src/material/chips/chip-option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class MatChipSelectionChange {
3939
* user cannot click disabled chips.
4040
*/
4141
@Component({
42-
selector: 'mat-basic-chip-option, mat-chip-option',
42+
selector: 'mat-basic-chip-option, [mat-basic-chip-option], mat-chip-option, [mat-chip-option]',
4343
templateUrl: 'chip-option.html',
4444
styleUrls: ['chip.css'],
4545
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],

src/material/chips/chip-row.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface MatChipEditedEvent extends MatChipEvent {
4444
* the matChipInputFor directive.
4545
*/
4646
@Component({
47-
selector: 'mat-chip-row, mat-basic-chip-row',
47+
selector: 'mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]',
4848
templateUrl: 'chip-row.html',
4949
styleUrls: ['chip.css'],
5050
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],

src/material/chips/chip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const _MatChipMixinBase = mixinTabIndex(
8080
* Extended by MatChipOption and MatChipRow for different interaction patterns.
8181
*/
8282
@Component({
83-
selector: 'mat-basic-chip, mat-chip',
83+
selector: 'mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]',
8484
inputs: ['color', 'disabled', 'disableRipple', 'tabIndex'],
8585
exportAs: 'matChip',
8686
templateUrl: 'chip.html',

tools/public_api_guard/material/chips.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class MatChip extends _MatChipMixinBase implements AfterViewInit, CanColo
114114
// (undocumented)
115115
protected _value: any;
116116
// (undocumented)
117-
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>;
117+
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>;
118118
// (undocumented)
119119
static ɵfac: i0.ɵɵFactoryDeclaration<MatChip, [null, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
120120
}
@@ -360,7 +360,7 @@ export class MatChipOption extends MatChip implements OnInit {
360360
_setSelectedState(isSelected: boolean, isUserInput: boolean, emitEvent: boolean): void;
361361
toggleSelected(isUserInput?: boolean): boolean;
362362
// (undocumented)
363-
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>;
363+
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>;
364364
// (undocumented)
365365
static ɵfac: i0.ɵɵFactoryDeclaration<MatChipOption, never>;
366366
}
@@ -399,7 +399,7 @@ export class MatChipRow extends MatChip implements AfterViewInit {
399399
_isEditing: boolean;
400400
_mousedown(event: MouseEvent): void;
401401
// (undocumented)
402-
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>;
402+
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>;
403403
// (undocumented)
404404
static ɵfac: i0.ɵɵFactoryDeclaration<MatChipRow, [null, null, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
405405
}

0 commit comments

Comments
 (0)