[ACS-4051] Copy to clipboard button is now accessible through the keyboard (#8225)

This commit is contained in:
Jatin Chugh
2023-02-03 02:23:30 +05:30
committed by GitHub
parent d50aa91922
commit 65e0c2405a
2 changed files with 24 additions and 7 deletions

View File

@@ -40,12 +40,6 @@ export class ClipboardDirective {
public viewContainerRef: ViewContainerRef,
private resolver: ComponentFactoryResolver) {}
@HostListener('click', ['$event'])
handleClickEvent(event: MouseEvent) {
event.preventDefault();
event.stopPropagation();
this.copyToClipboard();
}
@HostListener('mouseenter')
showTooltip() {
@@ -61,7 +55,12 @@ export class ClipboardDirective {
this.viewContainerRef.remove();
}
private copyToClipboard() {
@HostListener('keydown.enter', ['$event'])
@HostListener('click', ['$event'])
copyToClipboard(event: KeyboardEvent | MouseEvent): void {
event.preventDefault();
event.stopPropagation();
const isValidTarget = this.clipboardService.isTargetValid(this.target);
if (isValidTarget) {