Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B2B27200C1D for ; Thu, 2 Feb 2017 02:49:13 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B12E8160B5E; Thu, 2 Feb 2017 01:49:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0453E160B46 for ; Thu, 2 Feb 2017 02:49:12 +0100 (CET) Received: (qmail 9376 invoked by uid 500); 2 Feb 2017 01:49:12 -0000 Mailing-List: contact commits-help@zeppelin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.apache.org Delivered-To: mailing list commits@zeppelin.apache.org Received: (qmail 9366 invoked by uid 99); 2 Feb 2017 01:49:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Feb 2017 01:49:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1CE92DFC47; Thu, 2 Feb 2017 01:49:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: minalee@apache.org To: commits@zeppelin.apache.org Message-Id: <72377d1d74554fbfb9604344ce1d6e8f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: zeppelin git commit: [ZEPPELIN-2033] Handle focus/blur of paragraph with hidden editor Date: Thu, 2 Feb 2017 01:49:12 +0000 (UTC) archived-at: Thu, 02 Feb 2017 01:49:13 -0000 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 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 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 Authored: Tue Jan 31 19:02:15 2017 +0900 Committer: Mina Lee 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); } });