From d47ecc060c898c1773dcd2addff9e61d8799e9b9 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:01:35 -0700 Subject: [PATCH] [Enhancement] Keyboard shortcut for running queries (#8322) (#8491) * added keyboard listener * changed implementation to monaco action button * changed implementation to monaco action button * added space * Update src/plugins/data/public/ui/query_editor/query_editor.tsx * updated linter, added changesheet --------- (cherry picked from commit 57eea79f425079194c1f1c7d806a32aae0cd5b16) Signed-off-by: sumukhswamy Signed-off-by: Sumukh Swamy Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] Co-authored-by: Ashwin P Chandran --- changelogs/fragments/8322.yml | 2 ++ src/plugins/data/public/ui/query_editor/query_editor.tsx | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 changelogs/fragments/8322.yml diff --git a/changelogs/fragments/8322.yml b/changelogs/fragments/8322.yml new file mode 100644 index 000000000000..c44f12292b5f --- /dev/null +++ b/changelogs/fragments/8322.yml @@ -0,0 +1,2 @@ +fix: +- Keyboard shortcut for running queries ([#8322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8322)) \ No newline at end of file diff --git a/src/plugins/data/public/ui/query_editor/query_editor.tsx b/src/plugins/data/public/ui/query_editor/query_editor.tsx index 428aa7b70304..c31e28b48884 100644 --- a/src/plugins/data/public/ui/query_editor/query_editor.tsx +++ b/src/plugins/data/public/ui/query_editor/query_editor.tsx @@ -366,6 +366,14 @@ export default class QueryEditorUI extends Component { editor.setValue(`\n`.repeat(10)); this.setState({ lineCount: editor.getModel()?.getLineCount() }); this.inputRef = editor; + // eslint-disable-next-line no-bitwise + editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => { + this.onSubmit(this.props.query); + }); + + return () => { + disposable.dispose(); + }; }, footerItems: { start: [