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:48:56 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master 0589e27e7 -> fe11b32e8


[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


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

Branch: refs/heads/master
Commit: fe11b32e8c70a0ad8d1d206638bf3199a1042261
Parents: 0589e27
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:48:49 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/fe11b32e/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 da82080..342d41f 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -635,23 +635,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) {
@@ -746,6 +735,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);
@@ -1283,9 +1283,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) {
@@ -1303,11 +1300,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