Skip to content

Commit 76883cd

Browse files
committed
feat(chip): trailing remove icon can now be customized
1 parent 2a4db32 commit 76883cd

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

chips/internal/_trailing-icon.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
width: var(--_icon-size);
3636
}
3737

38-
[name="trailing-icon"]::slotted(md-icon) {
38+
[name="remove-trailing-icon"]::slotted(md-icon) {
3939
--md-icon-size: var(--_icon-size);
4040
color: inherit;
4141
}

chips/internal/filter-chip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {renderRemoveButton} from './trailing-icons.js';
2222
*/
2323
export class FilterChip extends MultiActionChip {
2424
@property({type: Boolean}) elevated = false;
25-
@property({type: Boolean, attribute: 'has-trailing'}) hasTrailing = false;
25+
@property({type: Boolean}) removable = false;
2626
@property({type: Boolean, reflect: true}) selected = false;
2727

2828
/**
@@ -84,7 +84,7 @@ export class FilterChip extends MultiActionChip {
8484
}
8585

8686
protected override renderTrailingAction(focusListener: EventListener) {
87-
if (this.hasTrailing) {
87+
if (this.removable) {
8888
return renderRemoveButton({
8989
focusListener,
9090
ariaLabel: this.ariaLabelRemove,

chips/internal/multi-action-chip.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ 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-
5445
constructor() {
5546
super();
5647
this.handleTrailingActionFocus = this.handleTrailingActionFocus.bind(this);

chips/internal/trailing-icons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function renderRemoveButton({
3434
@focus=${focusListener}>
3535
<md-focus-ring part="trailing-focus-ring"></md-focus-ring>
3636
<md-ripple ?disabled=${disabled}></md-ripple>
37-
<slot name="trailing-icon" class="trailing icon">
37+
<slot name="remove-trailing-icon" class="trailing icon">
3838
<svg viewBox="0 96 960 960" aria-hidden="true">
3939
<path
4040
d="m249 849-42-42 231-231-231-231 42-42 231 231 231-231 42 42-231 231 231 231-42 42-231-231-231 231Z" />
@@ -46,7 +46,7 @@ export function renderRemoveButton({
4646
}
4747

4848
function handleRemoveClick(this: MultiActionChip, event: Event) {
49-
if (this.disabled || this.hasSlottedTrailingIcon) {
49+
if (this.disabled) {
5050
return;
5151
}
5252

0 commit comments

Comments
 (0)