You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Key handling is broken in our Storybook stories. It works in examples outside Storybook, so the problem seems tied to the Storybook integration.
Describe the bug
I noticed the issue while migrating the Validation story to TypeScript. Arrow keys are not handled. I also tried with the legacy keyCode value 40 for ArrowDown and it still did not work.
Repros on Ubuntu with Chrome and Firefox. Both fail.
Works in ts-example outside Storybook. So this looks Storybook-specific.
Our current implementation uses event.keyCode which is deprecated.
On mxGraph, the same validation demo works in Firefox (checked on 2025-08-22).
Note
This might be related to not passing an explicit target node to the KeyHandler constructor in the stories.
Warning
The problem applies to all stories involving KeyHandler
I tried a few tweaks based on CodeRabbit recommendations but results were not conclusive yet. Further isolating focus and passing the target node explicitly seems the most promising path.
Tasks
Make it works in all stories.
Notice that the list here has been created based on the current usage of KeyHandler. Some usages are probably useless because in some stories, the KeyHandler is declared but no listener is registered.
In this case, the KeyHandler should be removed.
DynamicToolbar.stories.ts. Remove, KeyHandler is only instantiated
Editing.stories.js. Remove, KeyHandler is only instantiated
Guides.stories.ts
Indicators.stories.js. Remove, KeyHandler is only instantiated
Label.stories.js. Remove, KeyHandler is only instantiated
OrgChart.stories.js. Remove, KeyHandler is only instantiated
Permissions.stories.js
Scrollbars.stories.js. Remove, KeyHandler is only instantiated
Toolbar.stories.ts. Remove commented code related to KeyHandler
Tree.stories.js. Remove, KeyHandler is only instantiated
UserObject.stories.ts. Remove, KeyHandler is only instantiated
Describe the bug
I noticed the issue while migrating the Validation story to TypeScript. Arrow keys are not handled. I also tried with the legacy
keyCodevalue40for ArrowDown and it still did not work.ts-exampleoutside Storybook. So this looks Storybook-specific.event.keyCodewhich is deprecated.Warning
The problem applies to all stories involving
KeyHandlerLinks
Validation story migration PR: refactor: migrate the
Guidesstory to TypeScript #908Guidesstory to TypeScript #908 (review). This is a good start but this is not always working.mxGraph reference that works in FF: https://jgraph.github.io/mxgraph/javascript/examples/validation.html
MDN note about
keyCodedeprecation: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#browser_compatibilitySteps to Reproduce
Expected behavior
KeyHandlerin the story.ts-exampleand with mxGraph’s demo.Actual behavior
ts-example(outside Storybook), so it’s not a core logic regression.Environment
OS: Ubuntu
Browsers: Chrome and Firefox (both reproduce)
Context:
packages/examples/ts-exampleHypothesis
KeyHandleris created without an explicit target DOM node in stories, so it may attach todocumentwhile Storybook’s iframe steals focus.event.keyCodemay cause inconsistent behavior across browsers in modern setups. Probably not the issue here.If we don't succeed in making it work in Storybook, we could use an external example instead. We could implement the use case described in #716
Additional context
Guidesstory to TypeScript #908.Tasks
Make it works in all stories.
Notice that the list here has been created based on the current usage of KeyHandler. Some usages are probably useless because in some stories, the KeyHandler is declared but no listener is registered.
In this case, the KeyHandler should be removed.