storybook: onKeyUp event doesn't work after upgrade to Storybook 5.0.1
Describe the bug I have a React component that use the onKeyPress event and before the Storybook version 5.0.1 was working fine. However, after migrate to the last version, it stop working. Doing nothing.
To Reproduce
I have this React hook:
import { useEffect } from 'react'
import includes from 'lodash/includes'
export default function useOnKeyUp({ action, keyCodes = [], when = true }) {
useEffect(() => {
function onKeyUp(e) {
if (includes(keyCodes, e.keyCode) && when) {
action()
}
}
document.body.addEventListener('keyup', onKeyUp)
return () => document.body.removeEventListener('keyup', onKeyUp)
}, [when, action, keyCodes])
}
And I’m using a component that use this hook to close a modal:
// Close on press keyCodes (ex: ESCAPE or ENTER)
useOnBodyKeyUp({
action: closeModal,
keyCodes: keyCodesToClose,
when: isOpen,
})
Expected behavior To fire the event.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 19 (10 by maintainers)
I am using storybook for a wcag accessible component, and the keyboard shortcuts totally kill my component’s ability to function properly with it’s key bindings.
Is it possible to disable all of the storybook key bindings? That is what I would do if I could.
Yowza!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.35 containing PR #6578 that references this issue. Upgrade today to try it out!
Because it’s a pre-release you can find it on the
@nextNPM tag.Closing this issue. Please re-open if you think there’s still more to do.