Skip to content

Commit

Permalink
refactor(share): append copy-to-clipboard text area to component's ro…
Browse files Browse the repository at this point in the history
…ot element
  • Loading branch information
amoncaldas committed Dec 29, 2021
1 parent 581dec1 commit 4cbf7ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/fragments/forms/map-form/components/share/Share.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="share-container">
<div class="share-container" ref="shareContainer">
<v-btn class="open-share-btn" style="float:right; margin-top:0" small icon :title="$t('share.share')" @click="openShare()"><v-icon>share</v-icon></v-btn>
<v-dialog v-model="isShareModalOpen" max-width="600" :persistent="true" attach="body">
<box customClass="share-modal" v-model="isShareModalOpen" background="white" closable @closed="closeShare()">
Expand Down
10 changes: 5 additions & 5 deletions src/fragments/forms/map-form/components/share/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ export default {
* @returns {Boolean}
*/
copyToClipboard (str) {
const el = document.createElement('textarea')
el.value = str
document.body.appendChild(el)
el.select()
const tempTextArea = document.createElement('textarea')
tempTextArea.value = str
this.$refs.shareContainer.appendChild(tempTextArea)
tempTextArea.select()
const result = document.execCommand('copy')
document.body.removeChild(el)
document.body.removeChild(tempTextArea)
return result
},

Expand Down

0 comments on commit 4cbf7ee

Please sign in to comment.