From a0ce46b8b880c0a512c092e15f8912594bf34019 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Nov 2024 02:49:08 +1100 Subject: [PATCH] [8.x] [Lens] Add Esc key handling to lens_configuration_flyout (#198487) (#198789) # Backport This will backport the following commits from `main` to `8.x`: - [[Lens] Add Esc key handling to lens_configuration_flyout (#198487)](https://github.com/elastic/kibana/pull/198487) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Krzysztof Kowalczyk --- .../lens_configuration_flyout.tsx | 63 +++++++++++-------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/x-pack/plugins/lens/public/app_plugin/shared/edit_on_the_fly/lens_configuration_flyout.tsx b/x-pack/plugins/lens/public/app_plugin/shared/edit_on_the_fly/lens_configuration_flyout.tsx index ef452f20fdf7d..fd3bcdc8bed8a 100644 --- a/x-pack/plugins/lens/public/app_plugin/shared/edit_on_the_fly/lens_configuration_flyout.tsx +++ b/x-pack/plugins/lens/public/app_plugin/shared/edit_on_the_fly/lens_configuration_flyout.tsx @@ -17,6 +17,8 @@ import { EuiFlexGroup, EuiFlexItem, euiScrollBarStyles, + EuiWindowEvent, + keys, } from '@elastic/eui'; import { euiThemeVars } from '@kbn/ui-theme'; import type { Datatable } from '@kbn/expressions-plugin/public'; @@ -392,40 +394,51 @@ export function LensEditConfigurationFlyout({ getUserMessages, ]); + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === keys.ESCAPE) { + closeFlyout?.(); + setIsInlineFlyoutVisible(false); + } + }; + if (isLoading) return null; // Example is the Discover editing where we dont want to render the text based editor on the panel, neither the suggestions (for now) if (!canEditTextBasedQuery && hidesSuggestions) { return ( - - - + <> + {isInlineFlyoutVisible && } + + + + ); } return ( <> + {isInlineFlyoutVisible && }