zenorocha / clipboard.js

:scissors: Modern copy to clipboard. No Flash. Just 3kb gzipped :clipboard:
https://clipboardjs.com
MIT License
33.98k stars 3.98k forks source link

Fix #805 don't `blur()` the trigger after a clipboard action #807

Closed patrickhlauke closed 2 years ago

patrickhlauke commented 2 years ago

What kind of change does this PR introduce? (check at least one)

Does this PR introduce a breaking change? (check one)

If yes, please describe the impact and migration path for existing applications:

This PR reintroduces the behavior that used to be in clipboard.js following https://github.com/zenorocha/clipboard.js/pull/419 but that has since been reverted for some reason. As such, after a clipboard action, focus will remain/be on the trigger element, rather than the body. If applications rely on the focus to be gone/removed from the trigger button, they'll need to adapt to this.

The PR fulfills these requirements:

I didn't target v2.x branch because it looks wildly out of date.

Other information:

I'm not too hot on writing tests, so rather than just removing the check to see if focus is now on the body, it should probably explicitly check that focus remained on the trigger. However, not quite sure how to do that - my knowledge of test harnesses etc is pretty basic.

Closes #805

patrickhlauke commented 2 years ago

wonderful! thank you.