From ec38367b7073afe1107b00888305ebf02a695d6a Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 24 Oct 2017 17:37:51 -0700 Subject: [PATCH] [UI Framework] Improve KuiContextMenu keyboard navigation UX (#14434) * Refactor focus state logic to use the React lifecycle correctly. * Update KuiPopover snapshots. * Remove unnecessary isVisible prop from KuiContextMenu. * Allow user to both tab AND use the arrow keys for navigation. * Reinstate ability to tab and shift-tab to the title of KuiContextMenuPanel. * Release focus from Dashboard panel options KuiContextMenu by closing it when you select an option. * Update KuiContextMenu example to demonstrate best practice of closing the menu when an item is clicked. * Replace native transitionend event handler with onAnimationEnd React event handler. --- .../dashboard/panel/panel_options_menu.js | 24 ++- .../apps/dashboard/_panel_controls.js | 1 + ui_framework/dist/ui_framework.css | 8 +- .../src/views/context_menu/context_menu.js | 31 ++-- .../src/views/context_menu/single_panel.js | 24 +-- .../doc_site/src/views/popover/popover.js | 1 + .../views/popover/popover_anchor_position.js | 2 + .../views/popover/popover_body_class_name.js | 1 + .../views/popover/popover_panel_class_name.js | 1 + .../src/views/popover/popover_with_title.js | 1 + .../__snapshots__/context_menu.test.js.snap | 128 ++++++------- .../context_menu_panel.test.js.snap | 29 ++- .../context_menu/_context_menu_panel.scss | 7 + .../components/context_menu/context_menu.js | 40 ++-- .../context_menu/context_menu.test.js | 28 +-- .../context_menu/context_menu_panel.js | 173 ++++++++++-------- .../context_menu/context_menu_panel.test.js | 153 +++++++++++++++- .../__snapshots__/popover.test.js.snap | 27 +++ .../src/components/popover/popover.js | 22 ++- .../src/components/popover/popover.test.js | 29 +++ 20 files changed, 486 insertions(+), 244 deletions(-) diff --git a/src/core_plugins/kibana/public/dashboard/panel/panel_options_menu.js b/src/core_plugins/kibana/public/dashboard/panel/panel_options_menu.js index 641f90bc36129..fed9fbcfd22eb 100644 --- a/src/core_plugins/kibana/public/dashboard/panel/panel_options_menu.js +++ b/src/core_plugins/kibana/public/dashboard/panel/panel_options_menu.js @@ -18,12 +18,30 @@ export class PanelOptionsMenu extends React.Component { closePopover = () => this.setState({ isPopoverOpen: false }); + onEditPanel = () => { + this.closePopover(); + this.props.onEditPanel(); + }; + + onDeletePanel = () => { + this.closePopover(); + + if (this.props.onDeletePanel) { + this.props.onDeletePanel(); + } + }; + + onToggleExpandPanel = () => { + this.closePopover(); + this.props.onToggleExpandPanel(); + }; + renderItems() { const items = [(