docbrown/app/javascript/shared
Andrew Bone b7dfb2495a
Allow keyboard shortcuts (#10713)
* Create keyboardShortcuts.jsx

Add handler for keyboard shortcuts

* Match github's hotkey style

Makes objects clearer.

* Update keyboardShortcuts.jsx

* Allow single character shortcuts

update to allow single character shortcuts/hotkeys

* Add component documentation

Add inline documentation for the component.

* Fix example typo

* Move keyboardShortcuts to a hook

* Fixed useKeyboardShortcuts example

* Rename keyboardShortcuts.jsx to useKeyboardShortcuts.jsx

* Rebuild

* Move isFormField outside render cycle

Move the isFormField function outside of the render cycle.

* Prevent event listener on empty object

Don't add an event listener if the shortcuts property is an empty object or is null

* Add tests for useKeyboardShortcuts

Initial pass for adding tests to useKeyboardShortcuts

* Missed unmount

Missed a whole word...

* Fix typos

* Convert function type

* Add new test cases.

* Missing brackets

* Typo

* Update useKeyboardShortcuts.test.jsx

* Move event listener to document

* Update tests

* Use testing-library/user-event

* Correct fireEvent

* Update keyDown

* Slight tidy

* Change order, just in case

* Swap to render

* Make function async

* Rerun travis

* Add rerender

* Fix render function

* check event.key for fallback
2020-10-22 13:45:42 +02:00
..
components Allow keyboard shortcuts (#10713) 2020-10-22 13:45:42 +02:00