mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
[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.
This commit is contained in:
committed by
GitHub
parent
9ee78d16d4
commit
ed9a56b4ab
@@ -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 (
|
||||
<AceEditor
|
||||
@@ -136,7 +140,7 @@ class AceEditorWrapper extends React.PureComponent {
|
||||
onLoad={this.onEditorLoad.bind(this)}
|
||||
onBlur={this.onBlur.bind(this)}
|
||||
height={this.props.height}
|
||||
onChange={this.textChange.bind(this)}
|
||||
onChange={this.onChange}
|
||||
width="100%"
|
||||
editorProps={{ $blockScrolling: true }}
|
||||
enableLiveAutocompletion
|
||||
|
||||
Reference in New Issue
Block a user