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 default value for mapKey #1124

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

Conversation

nperez0111
Copy link

I ran into an issue using this library in IE11, luckily enough it was a very simple fix.

For some reason, I get undefined values in the mapKey functions and get the error:

Unable to get property 'trim' of undefined or null reference

So this fix just sets a default value for the mapKey function to ensure it never hits that error.

Normally, I'd just patch this on my own (no need for every package to support IE11 like I have to), but it was such a simple guard that I figured someone else would run into it eventually and it doesn't bloat anything.

I appreciate your work here, and hope you have a nice day!

This addresses an issue where IE11 (groan) at times does not set a key to map
Copy link

vercel bot commented Jan 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hotkeys-hook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2024 10:21am

@JohannesKlauss
Copy link
Owner

Thank you for your contribution, but this is not a sufficient fix. The typing of key is string so it shouldn't be undefined. If it is, the issue is somewhere else.

@nperez0111
Copy link
Author

Thank you for your contribution, but this is not a sufficient fix. The typing of key is string so it shouldn't be undefined. If it is, the issue is somewhere else.

I'm sorry but it is a bit hard to understand which key you are referring to.

If you are referring to your mapKey function, then we can easily modify that to say it accepts undefined now (e.g.key?: string).

But, I can assure that at runtime in IE11 (which may have non-standard event codes & key mappings given how old and out of spec it is) we do run into an undefined where a string should be.

Again, thank you for your time. I'll modify the PR to include the more liberal key type

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.

None yet

2 participants