mirror of
https://github.com/apache/superset.git
synced 2026-04-12 20:57:55 +00:00
[sql lab] fix sluggish backspace in editor (#3286)
Somehow Ace's "changeSelection" event is triggered when hitting backspace (and shouldn't!). changeSelection on our side triggers enough work to make the holding backspace sluggish and laggy. This fix ignores selection with a length of 1, avoiding mutating the state altogether when hitting/holding backspace.
This commit is contained in:
committed by
GitHub
parent
025ef5a0f1
commit
81817309d3
@@ -45,6 +45,7 @@ class AceEditorWrapper extends React.PureComponent {
|
||||
super(props);
|
||||
this.state = {
|
||||
sql: props.sql,
|
||||
selectedText: '',
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
@@ -77,8 +78,13 @@ class AceEditorWrapper extends React.PureComponent {
|
||||
});
|
||||
editor.$blockScrolling = Infinity; // eslint-disable-line no-param-reassign
|
||||
editor.selection.on('changeSelection', () => {
|
||||
this.props.actions.queryEditorSetSelectedText(
|
||||
this.props.queryEditor, editor.getSelectedText());
|
||||
const selectedText = editor.getSelectedText();
|
||||
// Backspace trigger 1 character selection, ignoring
|
||||
if (selectedText !== this.state.selectedText && selectedText.length !== 1) {
|
||||
this.setState({ selectedText });
|
||||
this.props.actions.queryEditorSetSelectedText(
|
||||
this.props.queryEditor, selectedText);
|
||||
}
|
||||
});
|
||||
}
|
||||
getCompletions(aceEditor, session, pos, prefix, callback) {
|
||||
|
||||
Reference in New Issue
Block a user