From b7604de36e9c1a774be7c2f1b7759170b2116f63 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 29 Mar 2018 14:32:03 -0700 Subject: [PATCH] [sql lab] ctrl-r hotkey should run latest SQL (#4719) Turns out the SQL would only be committed to the redux store `onBlur` event to avoid the laggy typing. The delay come from the localStorage binding that add enough millisecs of delay to feel odd while typing. I now store the most recent SQL in the local and use that instead. --- .../SqlLab/components/AceEditorWrapper.jsx | 12 ++++++++---- .../javascripts/SqlLab/components/SqlEditor.jsx | 11 +++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx b/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx index 24e9e25db630c..9a9b0379922c3 100644 --- a/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx +++ b/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx @@ -37,10 +37,12 @@ const propTypes = { descr: PropTypes.string.isRequired, func: PropTypes.func.isRequired, })), + onChange: PropTypes.func, }; const defaultProps = { onBlur: () => {}, + onChange: () => {}, tables: [], }; @@ -51,6 +53,7 @@ class AceEditorWrapper extends React.PureComponent { sql: props.sql, selectedText: '', }; + this.onChange = this.onChange.bind(this); } componentDidMount() { // Making sure no text is selected from previous mount @@ -97,6 +100,10 @@ class AceEditorWrapper extends React.PureComponent { } }); } + onChange(text) { + this.setState({ sql: text }); + this.props.onChange(text); + } getCompletions(aceEditor, session, pos, prefix, callback) { callback(null, this.state.words); } @@ -125,9 +132,6 @@ class AceEditorWrapper extends React.PureComponent { } }); } - textChange(text) { - this.setState({ sql: text }); - } render() { return (