Fix for 3rd Party Clients copy button (#962)

* Fix for 3rd Party Clients copy button

# Fixed
- Fixed: Fixed an issue where the copy button wasn't working on the "3rd Party Clients" page.

* Updating as per review request

* Buttoning up to be inline with spec
This commit is contained in:
Robbie Davis 2022-01-19 10:30:37 -05:00 committed by GitHub
parent 39a7bd4dc3
commit 506061094d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import { Subject } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators'; import { take, takeUntil } from 'rxjs/operators';
import { ConfirmService } from 'src/app/shared/confirm.service'; import { ConfirmService } from 'src/app/shared/confirm.service';
import { AccountService } from 'src/app/_services/account.service'; import { AccountService } from 'src/app/_services/account.service';
import { Clipboard } from '@angular/cdk/clipboard';
@Component({ @Component({
selector: 'app-api-key', selector: 'app-api-key',
@ -21,7 +22,7 @@ export class ApiKeyComponent implements OnInit, OnDestroy {
private readonly onDestroy = new Subject<void>(); private readonly onDestroy = new Subject<void>();
constructor(private confirmService: ConfirmService, private accountService: AccountService, private toastr: ToastrService) { } constructor(private confirmService: ConfirmService, private accountService: AccountService, private toastr: ToastrService, private clipboard: Clipboard) { }
ngOnInit(): void { ngOnInit(): void {
this.accountService.currentUser$.pipe(takeUntil(this.onDestroy)).subscribe(user => { this.accountService.currentUser$.pipe(takeUntil(this.onDestroy)).subscribe(user => {
@ -44,7 +45,9 @@ export class ApiKeyComponent implements OnInit, OnDestroy {
} }
async copy() { async copy() {
await navigator.clipboard.writeText(this.key); this.inputElem.nativeElement.select();
this.clipboard.copy(this.inputElem.nativeElement.value);
this.inputElem.nativeElement.setSelectionRange(0, 0);
} }
async refresh() { async refresh() {