Keep focus when copy Share-Link

Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
This commit is contained in:
Jonas Rittershofer 2020-05-30 08:51:59 +02:00
parent a7641c9e75
commit 8f2c62ddf7
3 changed files with 10 additions and 3 deletions

View file

@ -184,7 +184,7 @@ export default {
} }
}, },
async copyLink() { async copyLink(event) {
if (this.$clipboard(this.formLink)) { if (this.$clipboard(this.formLink)) {
this.copySuccess = true this.copySuccess = true
this.copied = true this.copied = true
@ -193,6 +193,9 @@ export default {
this.copied = true this.copied = true
console.debug('Not possible to copy share link') console.debug('Not possible to copy share link')
} }
// Set back focus as clipboard removes focus
event.target.focus()
setTimeout(() => { setTimeout(() => {
this.copySuccess = false this.copySuccess = false
this.copied = false this.copied = false

View file

@ -161,13 +161,15 @@ export default {
}) })
}, },
copyShareLink() { copyShareLink(event) {
const $formLink = window.location.protocol + '//' + window.location.host + generateUrl(`/apps/forms/${this.form.hash}`) const $formLink = window.location.protocol + '//' + window.location.host + generateUrl(`/apps/forms/${this.form.hash}`)
if (this.$clipboard($formLink)) { if (this.$clipboard($formLink)) {
showSuccess(t('forms', 'Form link copied')) showSuccess(t('forms', 'Form link copied'))
} else { } else {
showError(t('forms', 'Cannot copy, please copy the link manually')) showError(t('forms', 'Cannot copy, please copy the link manually'))
} }
// Set back focus as clipboard removes focus
event.target.focus()
}, },
async loadFormResults() { async loadFormResults() {

View file

@ -323,12 +323,14 @@ export default {
return datetime < moment().add(1, 'hour').toDate() return datetime < moment().add(1, 'hour').toDate()
}, },
copyShareLink() { copyShareLink(event) {
if (this.$clipboard(this.shareLink)) { if (this.$clipboard(this.shareLink)) {
showSuccess(t('forms', 'Form link copied')) showSuccess(t('forms', 'Form link copied'))
} else { } else {
showError(t('forms', 'Cannot copy, please copy the link manually')) showError(t('forms', 'Cannot copy, please copy the link manually'))
} }
// Set back focus as clipboard removes focus
event.target.focus()
}, },
}, },
} }