Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fixes vcopybutton focus (#1670)
Ramadan Omarb330d5b40fd6
diff --git a/src/components/VCopyButton.vue b/src/components/VCopyButton.vueindex 8bcc8c070..1ccc0c855 100644--- a/src/components/VCopyButton.vue+++ b/src/components/VCopyButton.vue@@ -46,6 +46,13 @@ export default defineComponent({const clipboard = ref<Clipboard | null>(null)const success = ref(false)+ function setFocusOnButton(): void {+ const button = document.getElementById(props.id)+ if (button) {+ button.focus()+ }+ }+const onCopySuccess = (e: Clipboard.Event) => {success.value = trueemit('copied', { content: e.text })@@ -55,10 +62,16 @@ export default defineComponent({}, 2000)e.clearSelection()++ /* Set the focus back on the button */+ setFocusOnButton()}const onCopyError = (e: Clipboard.Event) => {emit('copy-failed')e.clearSelection()++ /* Restore focus on the button */+ setFocusOnButton()}onMounted(() => {