zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mina...@apache.org
Subject zeppelin git commit: [ZEPPELIN-2033] Handle focus/blur of paragraph with hidden editor
Date Thu, 02 Feb 2017 01:49:12 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.7 1998e7b01 -> 76a813ed6


[ZEPPELIN-2033] Handle focus/blur of paragraph with hidden editor

### What is this PR for?
#1879 check if `$scope.editor` is null on `focusParagraph` message, and if it is, just return
without handling focus/blur.
Instead of doing null check in the beginning of `$scope.on(focusParagraph)`, I made null check
to be scoped only to `$scope.editor`'s method invocation.
FYI, when I say focus/blur, it means paragraph focus. Focused paragraph has different css
style from blurred paragraph.

### What type of PR is it?
Bug Fix | Hot Fix

### What is the Jira issue?
[ZEPPELIN-2033](https://issues.apache.org/jira/browse/ZEPPELIN-2033)

### How should this be tested?
Go to `Zeppelin Tutorial/Matplotlib (Python • PySpark)` notebook and see:
 - if first paragraph is blurred, when you click second paragraph.
 - if first paragraph is not run when you run second paragraph with shift + enter. In current
master, first editor is not blurred even if you click second paragraph, which makes both first
and second paragraph to be focused. This will make both paragraphs to be run.
 - if it is focused when you click third paragraph whose editor is hidden. In current master,
it won't work.

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Mina Lee <minalee@apache.org>

Closes #1963 from minahlee/ZEPPELIN-2033 and squashes the following commits:

3bf07ca [Mina Lee] Handle focus/blur of paragraph with hidden editor

(cherry picked from commit fe11b32e8c70a0ad8d1d206638bf3199a1042261)
Signed-off-by: Mina Lee <minalee@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/76a813ed
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/76a813ed
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/76a813ed

Branch: refs/heads/branch-0.7
Commit: 76a813ed698a798c5fedc8a22a4ce7bfd42176d9
Parents: 1998e7b
Author: Mina Lee <minalee@apache.org>
Authored: Tue Jan 31 19:02:15 2017 +0900
Committer: Mina Lee <minalee@apache.org>
Committed: Thu Feb 2 10:49:02 2017 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph.controller.js  | 37 ++++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/76a813ed/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index ef35b49..8659071 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -532,23 +532,12 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
         enableLiveAutocompletion: false
       });
 
-      $scope.handleFocus = function(value, isDigestPass) {
-        $scope.paragraphFocused = value;
-        if (isDigestPass === false || isDigestPass === undefined) {
-          // Protect against error in case digest is already running
-          $timeout(function() {
-            // Apply changes since they come from 3rd party library
-            $scope.$digest();
-          });
-        }
-      };
-
       $scope.editor.on('focus', function() {
-        $scope.handleFocus(true);
+        handleFocus(true);
       });
 
       $scope.editor.on('blur', function() {
-        $scope.handleFocus(false);
+        handleFocus(false);
       });
 
       $scope.editor.on('paste', function(e) {
@@ -643,6 +632,17 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
     }
   };
 
+  var handleFocus = function(value, isDigestPass) {
+    $scope.paragraphFocused = value;
+    if (isDigestPass === false || isDigestPass === undefined) {
+      // Protect against error in case digest is already running
+      $timeout(function() {
+        // Apply changes since they come from 3rd party library
+        $scope.$digest();
+      });
+    }
+  };
+
   var getEditorSetting = function(paragraph, interpreterName) {
     var deferred = $q.defer();
     websocketMsgSrv.getEditorSetting(paragraph.id, interpreterName);
@@ -1144,9 +1144,6 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
   });
 
   $scope.$on('focusParagraph', function(event, paragraphId, cursorPos, mouseEvent) {
-    if (!$scope.editor) {
-      return;
-    }
     if ($scope.paragraph.id === paragraphId) {
       // focus editor
       if (!$scope.paragraph.config.editorHide) {
@@ -1164,11 +1161,13 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams,
$locat
           $scope.scrollToCursor($scope.paragraph.id, 0);
         }
       }
-      $scope.handleFocus(true);
+      handleFocus(true);
     } else {
-      $scope.editor.blur();
+      if ($scope.editor !== undefined && $scope.editor !== null) {
+        $scope.editor.blur();
+      }
       var isDigestPass = true;
-      $scope.handleFocus(false, isDigestPass);
+      handleFocus(false, isDigestPass);
     }
   });
 


Mime
View raw message