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';
2222 */
2323export class FilterChip extends MultiActionChip {
2424 @property ( { type : Boolean } ) elevated = false ;
25- @property ( { type : Boolean } ) removable = false ;
25+ @property ( { type : Boolean , attribute : 'has-trailing' } ) hasTrailing = false ;
2626 @property ( { type : Boolean , reflect : true } ) selected = false ;
2727
2828 protected get primaryId ( ) {
@@ -39,7 +39,7 @@ export class FilterChip extends MultiActionChip {
3939 ...super . getContainerClasses ( ) ,
4040 elevated : this . elevated ,
4141 selected : this . selected ,
42- 'has-trailing' : this . removable ,
42+ 'has-trailing' : this . hasTrailing ,
4343 } ;
4444 }
4545
@@ -72,7 +72,7 @@ export class FilterChip extends MultiActionChip {
7272 }
7373
7474 protected override renderTrailingAction ( focusListener : EventListener ) {
75- if ( this . removable ) {
75+ if ( this . hasTrailing ) {
7676 return renderRemoveButton ( {
7777 focusListener,
7878 ariaLabel : this . ariaLabelRemove ,
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ export abstract class MultiActionChip extends Chip {
4242 protected abstract readonly primaryAction : HTMLElement | null ;
4343 protected abstract readonly trailingAction : HTMLElement | null ;
4444
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+
4554 constructor ( ) {
4655 super ( ) ;
4756 this . handleTrailingActionFocus = this . handleTrailingActionFocus . bind ( this ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import '../../ripple/ripple.js';
99
1010import { html , nothing } from 'lit' ;
1111
12- import { Chip } from './chip.js' ;
12+ import { MultiActionChip } from './multi-action- chip.js' ;
1313
1414interface RemoveButtonProperties {
1515 ariaLabel : string ;
@@ -45,8 +45,8 @@ export function renderRemoveButton({
4545 ` ;
4646}
4747
48- function handleRemoveClick ( this : Chip , event : Event ) {
49- if ( this . disabled ) {
48+ function handleRemoveClick ( this : MultiActionChip , event : Event ) {
49+ if ( this . disabled || this . hasSlottedTrailingIcon ) {
5050 return ;
5151 }
5252
You can’t perform that action at this time.
0 commit comments