NoriginMedia / Norigin-Spatial-Navigation

React Hooks based Spatial Navigation (Key & Remote Control Navigation) / Web Browsers, Smart TVs and Connected TVs
MIT License
315 stars 94 forks source link

fix: key code being undefined in some enviroments #97

Closed patricklizon closed 11 months ago

patricklizon commented 1 year ago

This PR fixes event detection in jsdom / happy-dom. Current solution uses deprecated keyCode property to trigger event handlers.

Testing component by emitting keyboard event with testing-library/user-event i.e.userEvent.keyboard("{arrowdown}") does not trigger callbacks defined in onArrowPress or onEnterPress handlers.

Adding an event code as a fallback fixes the issue.

predikament commented 12 months ago

Looks OK to me; @asgvard: What say ye?