File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import {renderRemoveButton} from './trailing-icons.js';
22
22
*/
23
23
export class FilterChip extends MultiActionChip {
24
24
@property ( { type : Boolean } ) elevated = false ;
25
- @property ( { type : Boolean } ) removable = false ;
25
+ @property ( { type : Boolean , attribute : 'has-trailing' } ) hasTrailing = false ;
26
26
@property ( { type : Boolean , reflect : true } ) selected = false ;
27
27
28
28
protected get primaryId ( ) {
@@ -39,7 +39,7 @@ export class FilterChip extends MultiActionChip {
39
39
...super . getContainerClasses ( ) ,
40
40
elevated : this . elevated ,
41
41
selected : this . selected ,
42
- 'has-trailing' : this . removable ,
42
+ 'has-trailing' : this . hasTrailing ,
43
43
} ;
44
44
}
45
45
@@ -72,7 +72,7 @@ export class FilterChip extends MultiActionChip {
72
72
}
73
73
74
74
protected override renderTrailingAction ( focusListener : EventListener ) {
75
- if ( this . removable ) {
75
+ if ( this . hasTrailing ) {
76
76
return renderRemoveButton ( {
77
77
focusListener,
78
78
ariaLabel : this . ariaLabelRemove ,
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ export abstract class MultiActionChip extends Chip {
42
42
protected abstract readonly primaryAction : HTMLElement | null ;
43
43
protected abstract readonly trailingAction : HTMLElement | null ;
44
44
45
+ /**
46
+ * Getter used to determine if the user provided a trailing icon or not.
47
+ */
48
+ get hasSlottedTrailingIcon ( ) {
49
+ const slot = this . shadowRoot . querySelector ( 'slot[name="trailing-icon"]' ) as HTMLSlotElement ;
50
+ // Default slot is not counted as one element.
51
+ return slot . assignedElements ( ) . length > 0 ;
52
+ }
53
+
45
54
constructor ( ) {
46
55
super ( ) ;
47
56
this . handleTrailingActionFocus = this . handleTrailingActionFocus . bind ( this ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import '../../ripple/ripple.js';
9
9
10
10
import { html , nothing } from 'lit' ;
11
11
12
- import { Chip } from './chip.js' ;
12
+ import { MultiActionChip } from './multi-action- chip.js' ;
13
13
14
14
interface RemoveButtonProperties {
15
15
ariaLabel : string ;
@@ -45,8 +45,8 @@ export function renderRemoveButton({
45
45
` ;
46
46
}
47
47
48
- function handleRemoveClick ( this : Chip , event : Event ) {
49
- if ( this . disabled ) {
48
+ function handleRemoveClick ( this : MultiActionChip , event : Event ) {
49
+ if ( this . disabled || this . hasSlottedTrailingIcon ) {
50
50
return ;
51
51
}
52
52
You can’t perform that action at this time.
0 commit comments