[Canvas] Refactor keyboard shortcut handlers #42628
Labels
chore
Feature:Canvas
impact:medium
Addressing this issue will have a medium level of impact on the quality/strength of our product.
loe:medium
Medium Level of Effort
Team:Presentation
Presentation Team for Dashboard, Input Controls, and Canvas
We've run into a few issues where shortcuts have been disabled accidentally and other issues surrounding the keyboard shortcut handlers where key events have been swallowed.
We currently use the
Shortcut
component from thereact-shortcuts
package to handle shortcuts. Some of these are rendered conditionally based on the current app state. There are multiple instances of theShortcut
components across the app that should handle different types of shortcuts, i.e. element shortcuts vs expression editor shortcuts, but I've noticed there's some overlap in some of the handlers where the same shortcuts are being handled different in two places.We should audit the handlers and potentially reorganize the namespaces for the keymap and introduce global apps. We also need to double check that the correct props are being passed into each component per concern so the handlers don't clash and fire when they're not support to.
I think it'd also be beneficial to refactor the handlers and place them in a centralized location where we can see all of the shortcuts at once. This should help with making sure changes are applied to the shortcuts consistently, so we don't accidentally miss one of the shortcuts handlers.
TODOs:
GLOBAL
namespace for shortcuts that should always be available regardless of the current app state, like refresh or toggle fullscreen mode<Shortcut />
instances into a single component (is this actually something we want to do?)Shortcut handler locations:
kibana/x-pack/legacy/plugins/canvas/public/components/expression/expression.js
Line 30 in 396edb9
kibana/x-pack/legacy/plugins/canvas/public/components/workpad_header/fullscreen_control/fullscreen_control.js
Line 41 in 396edb9
kibana/x-pack/legacy/plugins/canvas/public/components/workpad_shortcuts/workpad_shortcuts.tsx
Line 118 in 396edb9
kibana/x-pack/legacy/plugins/canvas/public/components/workpad/workpad.js
Line 126 in 396edb9
Shortcut Availability
react-shortcuts
. Move this to element controls?react-shortcuts
. Move this to element controls?react-shortcuts
react-shortcuts
editor
namespaceThe text was updated successfully, but these errors were encountered: