From 8f2c62ddf75200ed7f960177e36269720166d158 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Sat, 30 May 2020 08:51:59 +0200 Subject: [PATCH] Keep focus when copy Share-Link Signed-off-by: Jonas Rittershofer --- src/components/AppNavigationForm.vue | 5 ++++- src/views/Results.vue | 4 +++- src/views/Sidebar.vue | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/AppNavigationForm.vue b/src/components/AppNavigationForm.vue index 053b6fd..498afaf 100644 --- a/src/components/AppNavigationForm.vue +++ b/src/components/AppNavigationForm.vue @@ -184,7 +184,7 @@ export default { } }, - async copyLink() { + async copyLink(event) { if (this.$clipboard(this.formLink)) { this.copySuccess = true this.copied = true @@ -193,6 +193,9 @@ export default { this.copied = true console.debug('Not possible to copy share link') } + // Set back focus as clipboard removes focus + event.target.focus() + setTimeout(() => { this.copySuccess = false this.copied = false diff --git a/src/views/Results.vue b/src/views/Results.vue index b95f36a..325472d 100644 --- a/src/views/Results.vue +++ b/src/views/Results.vue @@ -161,13 +161,15 @@ export default { }) }, - copyShareLink() { + copyShareLink(event) { const $formLink = window.location.protocol + '//' + window.location.host + generateUrl(`/apps/forms/${this.form.hash}`) if (this.$clipboard($formLink)) { showSuccess(t('forms', 'Form link copied')) } else { showError(t('forms', 'Cannot copy, please copy the link manually')) } + // Set back focus as clipboard removes focus + event.target.focus() }, async loadFormResults() { diff --git a/src/views/Sidebar.vue b/src/views/Sidebar.vue index 81bf839..56ed6b8 100644 --- a/src/views/Sidebar.vue +++ b/src/views/Sidebar.vue @@ -323,12 +323,14 @@ export default { return datetime < moment().add(1, 'hour').toDate() }, - copyShareLink() { + copyShareLink(event) { if (this.$clipboard(this.shareLink)) { showSuccess(t('forms', 'Form link copied')) } else { showError(t('forms', 'Cannot copy, please copy the link manually')) } + // Set back focus as clipboard removes focus + event.target.focus() }, }, }