Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed loss of focus when clicking the Copy button #867

Merged
merged 1 commit into from
Apr 23, 2019

Conversation

ffissore
Copy link
Contributor

When the Copy button is pressed, focus is lost and scrolling the page with the arrow keys stops working. Fixed by giving focus back to the trigger object (clipboard.js provided) which is the copy button itself

@ffissore
Copy link
Contributor Author

Steps to reproduce:

  1. open the example book, open a page with a code block
  2. try scrolling using your keyboard arrow keys, verify it works
  3. click on any "copy" button on the right side of a code block
  4. try again to scroll using the arrow keys, verify it's not working any more

@ehuss
Copy link
Contributor

ehuss commented Apr 23, 2019

This seems to work.

An alternative is to update the version of clipboard.js to the latest (2.0.4) which already has this fix (zenorocha/clipboard.js#419). AFAICT, the only change necessary to switch to 2.0 is to use the constructor ClipboardJS instead of Clipboard (details are in https://github.com/zenorocha/clipboard.js/releases).

with the arrow keys stops working. Fixed by upgrading ClipboardJS to
the latest version
@ffissore
Copy link
Contributor Author

Thanks for the hint. Delegating the fix to ClipboardJS makes much more sense. I've updated the PR accordingly

@Dylan-DPC-zz Dylan-DPC-zz merged commit 99dc62f into rust-lang:master Apr 23, 2019
@Dylan-DPC-zz
Copy link

Thanks

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
Fixed loss of focus when clicking the Copy button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants