Skip to content

Commit 8cebaa4

Browse files
authored
feat(webui): Trigger submit action when pressing Enter on Monaco single line editor. (#1459)
1 parent 94ce817 commit 8cebaa4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

components/webui/client/src/components/SqlInput/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Reference: https://github.com/vikyd/vue-monaco-singleline
22
import {useCallback} from "react";
33

4+
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
5+
46
import SqlEditor, {
57
SqlEditorProps,
68
SqlEditorType,
@@ -26,6 +28,18 @@ const SqlInput = (props: SqlEditorProps) => {
2628
});
2729
}
2830
});
31+
32+
// Add action to simulate form submission on Enter key
33+
editor.addAction({
34+
id: "run-query",
35+
label: "Run Query",
36+
keybindings: [monaco.KeyCode.Enter],
37+
run: () => {
38+
const formEl = editor.getDomNode()?.closest("form");
39+
const submitBtn = formEl?.querySelector<HTMLButtonElement>('button[type="submit"]');
40+
submitBtn?.click();
41+
},
42+
});
2943
}, []);
3044

3145
return (

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/CancelButton/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const CancelButton = () => {
4545
<Button
4646
className={styles["cancelButton"] || ""}
4747
color={"red"}
48+
htmlType={"button"}
4849
icon={<CloseOutlined/>}
4950
size={"middle"}
5051
variant={"solid"}

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const GuidedRunButton = () => {
8989
<Button
9090
className={styles["runButton"] || ""}
9191
color={"green"}
92+
htmlType={"submit"}
9293
icon={<CaretRightOutlined/>}
9394
size={"middle"}
9495
variant={"solid"}

0 commit comments

Comments
 (0)