Inndy / vue-clipboard2

A simple vue2 binding to clipboard.js
https://vue-clipboard2.inndy.tw/
MIT License
1.77k stars 242 forks source link

Focus must stay on the link/button #105

Open PVince81 opened 4 years ago

PVince81 commented 4 years ago

Steps to reproduce

  1. Run the sample app
  2. Focus on the text field
  3. Now tab to the "Copy Text" button

Expected result

Keyboard focus stays on "Copy Text"

Actual result

Focus moves to the next field.

Version

Happens on vue-clipboard2 git master 8a542c558c6857212d06f6fc1929384a5b5104cc and also on version 0.3.1

Further notes

If you remove the "v-clipboard:copy" attribute and retest you can see that the focus stays.

The problem also happens when using $copyText.

brd6 commented 3 years ago

I have the same issue, a workaround is to reset the focus on the text field after copy.

  this.$copyText('my content').then(() => {
    this.$refs.mytextFieldInput.focus();
  });