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

Fix to make Copy/Paste keyboard shortcuts working with useSelection #302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Edouard-Tby
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

The aim of this PR is to fix issue #272 => Copy/Paste/Refresh keyboard shortcuts not working if using useSelection Hook

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #272

What is the new behavior?

Copy paste is now working (you can try it for instance on the text 'Hold Cammand/CTRL ....') in the Modifier Key section.

image

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

Copy link

netlify bot commented Jan 2, 2025

Deploy Preview for reagraph ready!

Name Link
🔨 Latest commit 56a509d
🔍 Latest deploy log https://app.netlify.com/sites/reagraph/deploys/677bbaaa13d7960008fad3d3
😎 Deploy Preview https://deploy-preview-302--reagraph.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

const isSafe =
element.tagName !== 'INPUT' &&
element.tagName !== 'SELECT' &&
element.tagName !== 'TEXTAREA' &&
!element.isContentEditable;

const isMeta = event.metaKey || event.ctrlKey;
const isSystemShortcut = ['c', 'x', 'v'].includes(event.key.toLowerCase());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right approach considering this could change based on user hotkey or locale. I think removing the preventDefault is probably the right move, I don't remember why we added that in the first place, can u test it doesn't break anything if removed and update to just remove that instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems better indeed. I just tested and it works fine.

@Edouard-Tby Edouard-Tby requested a review from amcdnl January 6, 2025 11:15
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.

2 participants