From 88e98d576c12a0802c71315b5f089be834d0774b Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Mon, 24 Oct 2022 09:51:22 -0700 Subject: [PATCH] fix(sqllab): fix control x to stop query (#21899) --- .../src/SqlLab/components/SqlEditor/index.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx index 6ff9877cfb4a..4db8c748a5db 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx @@ -219,6 +219,7 @@ const SqlEditor = ({ if (latestQuery && ['running', 'pending'].indexOf(latestQuery.state) >= 0) { dispatch(postStopQuery(latestQuery)); } + return false; }; const runQuery = () => { @@ -244,7 +245,6 @@ const SqlEditor = ({ const getHotkeyConfig = () => { // Get the user's OS const userOS = detectOS(); - const base = [ { name: 'runQuery1', @@ -326,18 +326,21 @@ const SqlEditor = ({ window.addEventListener('resize', handleWindowResizeWithThrottle); window.addEventListener('beforeunload', onBeforeUnload); - // setup hotkeys - const hotkeys = getHotkeyConfig(); - hotkeys.forEach(keyConfig => { - Mousetrap.bind([keyConfig.key], keyConfig.func); - }); - return () => { window.removeEventListener('resize', handleWindowResizeWithThrottle); window.removeEventListener('beforeunload', onBeforeUnload); }; }, []); + useEffect(() => { + // setup hotkeys + Mousetrap.reset(); + const hotkeys = getHotkeyConfig(); + hotkeys.forEach(keyConfig => { + Mousetrap.bind([keyConfig.key], keyConfig.func); + }); + }, [latestQuery]); + const onResizeStart = () => { // Set the heights on the ace editor and the ace content area after drag starts // to smooth out the visual transition to the new heights when drag ends