This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 8181730  [sql lab] fix sluggish backspace in editor (#3286)
8181730 is described below

commit 81817309d3f1e19636fdc310ca3b393ccabe254a
Author: Maxime Beauchemin <maximebeauche...@gmail.com>
AuthorDate: Mon Aug 14 17:55:30 2017 -0700

    [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.
---
 .../assets/javascripts/SqlLab/components/AceEditorWrapper.jsx  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx 
b/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
index 37b884a..15adf0b 100644
--- a/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
+++ b/superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
@@ -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) {

-- 
To stop receiving notification emails like this one, please contact
['"comm...@superset.apache.org" <comm...@superset.apache.org>'].

Reply via email to