@@ -20,25 +20,22 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
2020import { _StructuralStylesLoader } from '../core' ;
2121
2222/**
23- * Section within a chip.
23+ * A non-interactive section of a chip.
2424 * @docs -private
2525 */
2626@Directive ( {
27- selector : '[matChipAction ]' ,
27+ selector : '[matChipContent ]' ,
2828 host : {
29- 'class' : 'mdc-evolution-chip__action mat-mdc-chip-action' ,
29+ 'class' :
30+ 'mat-mdc-chip-action mdc-evolution-chip__action mdc-evolution-chip__action--presentational' ,
3031 '[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
31- '[class.mdc-evolution-chip__action--presentational]' : '!isInteractive' ,
3232 '[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
3333 '[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
34- '[attr.tabindex]' : '_getTabindex()' ,
3534 '[attr.disabled]' : '_getDisabledAttribute()' ,
3635 '[attr.aria-disabled]' : 'disabled' ,
37- '(click)' : '_handleClick($event)' ,
38- '(keydown)' : '_handleKeydown($event)' ,
3936 } ,
4037} )
41- export class MatChipAction {
38+ export class MatChipContent {
4239 _elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
4340 protected _parentChip = inject < {
4441 _handlePrimaryActionInteraction ( ) : void ;
@@ -48,9 +45,6 @@ export class MatChipAction {
4845 _isEditing ?: boolean ;
4946 } > ( MAT_CHIP ) ;
5047
51- /** Whether the action is interactive. */
52- @Input ( ) isInteractive = true ;
53-
5448 /** Whether this is the primary action in the chip. */
5549 _isPrimary = true ;
5650
@@ -88,15 +82,6 @@ export class MatChipAction {
8882 return this . disabled && ! this . _allowFocusWhenDisabled ? '' : null ;
8983 }
9084
91- /**
92- * Determine the value of the tabindex attribute for this chip action.
93- */
94- protected _getTabindex ( ) : string | null {
95- return ( this . disabled && ! this . _allowFocusWhenDisabled ) || ! this . isInteractive
96- ? null
97- : this . tabIndex . toString ( ) ;
98- }
99-
10085 constructor ( ...args : unknown [ ] ) ;
10186
10287 constructor ( ) {
@@ -109,9 +94,31 @@ export class MatChipAction {
10994 focus ( ) {
11095 this . _elementRef . nativeElement . focus ( ) ;
11196 }
97+ }
98+
99+ /**
100+ * Interactive section of a chip.
101+ * @docs -private
102+ */
103+ @Directive ( {
104+ selector : '[matChipAction]' ,
105+ host : {
106+ '[attr.tabindex]' : '_getTabindex()' ,
107+ '[class.mdc-evolution-chip__action--presentational]' : 'false' ,
108+ '(click)' : '_handleClick($event)' ,
109+ '(keydown)' : '_handleKeydown($event)' ,
110+ } ,
111+ } )
112+ export class MatChipAction extends MatChipContent {
113+ /**
114+ * Determine the value of the tabindex attribute for this chip action.
115+ */
116+ protected _getTabindex ( ) : string | null {
117+ return this . disabled && ! this . _allowFocusWhenDisabled ? null : this . tabIndex . toString ( ) ;
118+ }
112119
113120 _handleClick ( event : MouseEvent ) {
114- if ( ! this . disabled && this . isInteractive && this . _isPrimary ) {
121+ if ( ! this . disabled && this . _isPrimary ) {
115122 event . preventDefault ( ) ;
116123 this . _parentChip . _handlePrimaryActionInteraction ( ) ;
117124 }
@@ -121,7 +128,6 @@ export class MatChipAction {
121128 if (
122129 ( event . keyCode === ENTER || event . keyCode === SPACE ) &&
123130 ! this . disabled &&
124- this . isInteractive &&
125131 this . _isPrimary &&
126132 ! this . _parentChip . _isEditing
127133 ) {
0 commit comments