-
Notifications
You must be signed in to change notification settings - Fork 811
Description
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:
react-modal/src/components/ModalPortal.js
Lines 276 to 285 in 0847049
| 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!