Skip to content

Commit

Permalink
Handle focus/blur of paragraph with hidden editor
Browse files Browse the repository at this point in the history
  • Loading branch information
minahlee committed Jan 31, 2017
1 parent 42bcf42 commit 3bf07ca
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
});

Expand Down

0 comments on commit 3bf07ca

Please sign in to comment.