diff --git a/src/Explorer/QueryCopilot/QueryCopilotTab.tsx b/src/Explorer/QueryCopilot/QueryCopilotTab.tsx index 5560a4703..4f32fe990 100644 --- a/src/Explorer/QueryCopilot/QueryCopilotTab.tsx +++ b/src/Explorer/QueryCopilot/QueryCopilotTab.tsx @@ -297,6 +297,12 @@ export const QueryCopilotTab: React.FC = ({ setShowCallout(false); }; + const startGenerateQueryProcess = () => { + updateHistories(); + generateSQLQuery(); + resetButtonState(); + }; + React.useEffect(() => { useCommandBar.getState().setContextButtons(getCommandbarButtons()); }, [query, selectedQuery]); @@ -325,6 +331,11 @@ export const QueryCopilotTab: React.FC = ({ inputEdited.current = true; setShowSamplePrompts(true); }} + onKeyDown={(e) => { + if (e.key === "Enter") { + startGenerateQueryProcess(); + } + }} style={{ lineHeight: 30 }} styles={{ root: { width: "95%" } }} disabled={isGeneratingQuery} @@ -357,11 +368,7 @@ export const QueryCopilotTab: React.FC = ({ iconProps={{ iconName: "Send" }} disabled={isGeneratingQuery || !userPrompt.trim()} style={{ marginLeft: 8 }} - onClick={() => { - updateHistories(); - generateSQLQuery(); - resetButtonState(); - }} + onClick={() => startGenerateQueryProcess()} /> {isGeneratingQuery && } {showSamplePrompts && ( diff --git a/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap b/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap index 86aa4fcb9..63f70e7ae 100644 --- a/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap +++ b/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap @@ -54,6 +54,7 @@ exports[`Query copilot tab snapshot test should render with initial input 1`] = id="naturalLanguageInput" onChange={[Function]} onClick={[Function]} + onKeyDown={[Function]} style={ Object { "lineHeight": 30,