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

Support of shortcuts for React v16 #128

Closed
Pareder opened this issue Jul 11, 2022 · 2 comments
Closed

Support of shortcuts for React v16 #128

Pareder opened this issue Jul 11, 2022 · 2 comments

Comments

@Pareder
Copy link

Pareder commented Jul 11, 2022

In onKeyDown handler by default there is a check for event.code property (https://github.com/uiwjs/react-textarea-code-editor/blob/main/src/shortcuts.ts#L7), but this property was added to event only in React v17 (https://blog.saeloun.com/2021/04/23/react-keyboard-event-code.html). Before that we can get it via event.nativeEvent.code accessor. In peerDependencies you have "react": ">=16.9.0" (https://github.com/uiwjs/react-textarea-code-editor/blob/main/package.json#L66), so maybe it is better to extend check in shortcuts method? Something like that:

const code = event.code || event.nativeEvent.code;
@Pareder
Copy link
Author

Pareder commented Jul 11, 2022

Great job, thank you!

jaywcjlove added a commit that referenced this issue Jul 11, 2022
@jaywcjlove
Copy link
Member

@Pareder Upgrade v2.0.3

github-actions bot pushed a commit that referenced this issue Jul 11, 2022
@Pareder Pareder closed this as completed Jul 11, 2022
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

No branches or pull requests

2 participants