Skip to content

Commit

Permalink
chore: activate state layer animation when anchor is triggered via en…
Browse files Browse the repository at this point in the history
…ter or space key
  • Loading branch information
DRiFTy17 committed Feb 23, 2024
1 parent 4fe3264 commit 56dcb31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/chips/chip/chip-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { replaceElement } from '../../core/utils/utils';

export interface IChipAdapter extends IBaseAdapter {
readonly removeButtonElement: IIconButtonComponent | undefined;
readonly isAnchor: boolean;
clickTrigger(): void;
addRootListener(type: string, listener: EventListener): void;
removeRootListener(type: string, listener: EventListener): void;
Expand All @@ -28,6 +29,7 @@ export interface IChipAdapter extends IBaseAdapter {
focusTrigger(options?: FocusOptions): void;
tryFocusRemoveButton(): void;
clickRemoveButton(): void;
animateStateLayer(): void;
}


Expand All @@ -53,6 +55,10 @@ export class ChipAdapter extends BaseAdapter<IChipComponent> implements IChipAda
return this._removeButtonElement;
}

public get isAnchor(): boolean {
return this._triggerElement.localName === 'a';
}

public clickTrigger(): void {
this._triggerElement.click();
}
Expand Down Expand Up @@ -198,6 +204,10 @@ export class ChipAdapter extends BaseAdapter<IChipComponent> implements IChipAda
this._removeButtonElement?.click();
}

public animateStateLayer(): void {
this._stateLayerElement.playAnimation();
}

private _createRemoveButton(): IIconButtonComponent {
const buttonEl = document.createElement('forge-icon-button');
buttonEl.density = 'small';
Expand Down
3 changes: 3 additions & 0 deletions src/lib/chips/chip/chip-foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export class ChipFoundation implements IChipFoundation {
}
} else {
this.click();
if (this._adapter.isAnchor) {
this._adapter.animateStateLayer();
}
}
break;
case 'ArrowLeft':
Expand Down

0 comments on commit 56dcb31

Please sign in to comment.