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

Switch from KeyboardEvent.keyCode to KeyboardEvent.code #952

Closed
robinmetral opened this issue Jun 13, 2022 · 2 comments · Fixed by #953
Closed

Switch from KeyboardEvent.keyCode to KeyboardEvent.code #952

robinmetral opened this issue Jun 13, 2022 · 2 comments · Fixed by #953

Comments

@robinmetral
Copy link
Contributor

Hi! First of all, apologies for removing the issue template—since this isn't a bug report, I've found it hard to fill the reproduction steps.

I'm wondering if there's anything stopping us from switching from the deprecated KeyboardEvent.keyCode to KeyboardEvent.code in the ModalPortal:

handleKeyDown = event => {
if (event.keyCode === TAB_KEY) {
scopeTab(this.content, event);
}
if (this.props.shouldCloseOnEsc && event.keyCode === ESC_KEY) {
event.stopPropagation();
this.requestClose(event);
}
};

We should probably stop relying on the deprecated property, and since React 18 dropped support for IE (which didn't support KeyboardEvent.code), I can't think of any blockers.

Using the deprecated property can already cause issues in browsers (or testing environments) that have removed support for it. I've ran into this using @testing-library/user-event (ref).

Happy to submit a PR for this!

@diasbruno
Copy link
Collaborator

Hi, if it has been deprecated, we need to update.

PRs are always welcome.

@robinmetral
Copy link
Contributor Author

Awesome, thanks for the reply—will submit some time this week 🙂

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 a pull request may close this issue.

2 participants