@@ -20,25 +20,22 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
20
20
import { _StructuralStylesLoader } from '../core' ;
21
21
22
22
/**
23
- * Section within a chip.
23
+ * A non-interactive section of a chip.
24
24
* @docs -private
25
25
*/
26
26
@Directive ( {
27
- selector : '[matChipAction ]' ,
27
+ selector : '[matChipContent ]' ,
28
28
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' ,
30
31
'[class.mdc-evolution-chip__action--primary]' : '_isPrimary' ,
31
- '[class.mdc-evolution-chip__action--presentational]' : '!isInteractive' ,
32
32
'[class.mdc-evolution-chip__action--secondary]' : '!_isPrimary' ,
33
33
'[class.mdc-evolution-chip__action--trailing]' : '!_isPrimary && !_isLeading' ,
34
- '[attr.tabindex]' : '_getTabindex()' ,
35
34
'[attr.disabled]' : '_getDisabledAttribute()' ,
36
35
'[attr.aria-disabled]' : 'disabled' ,
37
- '(click)' : '_handleClick($event)' ,
38
- '(keydown)' : '_handleKeydown($event)' ,
39
36
} ,
40
37
} )
41
- export class MatChipAction {
38
+ export class MatChipContent {
42
39
_elementRef = inject < ElementRef < HTMLElement > > ( ElementRef ) ;
43
40
protected _parentChip = inject < {
44
41
_handlePrimaryActionInteraction ( ) : void ;
@@ -48,9 +45,6 @@ export class MatChipAction {
48
45
_isEditing ?: boolean ;
49
46
} > ( MAT_CHIP ) ;
50
47
51
- /** Whether the action is interactive. */
52
- @Input ( ) isInteractive = true ;
53
-
54
48
/** Whether this is the primary action in the chip. */
55
49
_isPrimary = true ;
56
50
@@ -88,15 +82,6 @@ export class MatChipAction {
88
82
return this . disabled && ! this . _allowFocusWhenDisabled ? '' : null ;
89
83
}
90
84
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
-
100
85
constructor ( ...args : unknown [ ] ) ;
101
86
102
87
constructor ( ) {
@@ -109,9 +94,31 @@ export class MatChipAction {
109
94
focus ( ) {
110
95
this . _elementRef . nativeElement . focus ( ) ;
111
96
}
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
+ }
112
119
113
120
_handleClick ( event : MouseEvent ) {
114
- if ( ! this . disabled && this . isInteractive && this . _isPrimary ) {
121
+ if ( ! this . disabled && this . _isPrimary ) {
115
122
event . preventDefault ( ) ;
116
123
this . _parentChip . _handlePrimaryActionInteraction ( ) ;
117
124
}
@@ -121,7 +128,6 @@ export class MatChipAction {
121
128
if (
122
129
( event . keyCode === ENTER || event . keyCode === SPACE ) &&
123
130
! this . disabled &&
124
- this . isInteractive &&
125
131
this . _isPrimary &&
126
132
! this . _parentChip . _isEditing
127
133
) {
0 commit comments