Skip to content

Commit

Permalink
fix(textangular): Fix focus issues in IE11
Browse files Browse the repository at this point in the history
Fixes #443
  • Loading branch information
SimeonC authored and SimeonC committed Jan 4, 2015
1 parent efcb411 commit a5200e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/main.js
Expand Up @@ -375,6 +375,7 @@ textAngular.directive("textAngular", [
// note that focusout > focusin is called everytime we click a button - except bad support: http://www.quirksmode.org/dom/events/blurfocus.html
// cascades to displayElements.text and displayElements.html automatically.
_focusin = function(){
scope.focussed = true;
element.addClass(scope.classes.focussed);
_toolbars.focus();
};
Expand All @@ -389,6 +390,7 @@ textAngular.directive("textAngular", [
$timeout(function(){
scope._bUpdateSelectedStyles = false;
element.triggerHandler('blur');
scope.focussed = false;
}, 0);
}
e.preventDefault();
Expand Down Expand Up @@ -533,7 +535,10 @@ textAngular.directive("textAngular", [
// the following is for applying the active states to the tools that support it
scope._bUpdateSelectedStyles = false;
/* istanbul ignore next: browser window/tab leave check */
angular.element(window).on('blur', function(){ scope._bUpdateSelectedStyles = false; });
angular.element(window).on('blur', function(){
scope._bUpdateSelectedStyles = false;
scope.focussed = false;
});
// loop through all the tools polling their activeState function if it exists
scope.updateSelectedStyles = function(){
var _selection;
Expand All @@ -547,6 +552,11 @@ textAngular.directive("textAngular", [
};
// start updating on keydown
_keydown = function(){
/* istanbul ignore next: ie catch */
if(!scope.focussed){
scope._bUpdateSelectedStyles = false;
return;
}
/* istanbul ignore else: don't run if already running */
if(!scope._bUpdateSelectedStyles){
scope._bUpdateSelectedStyles = true;
Expand Down Expand Up @@ -637,6 +647,7 @@ textAngular.service('textAngularManager', ['taToolExecuteAction', 'taTools', 'ta
toolbarScope._parent = scope;
toolbarScope.disabled = false;
toolbarScope.focussed = true;
scope.focussed = true;
});
},
unfocus: function(){
Expand All @@ -645,6 +656,7 @@ textAngular.service('textAngularManager', ['taToolExecuteAction', 'taTools', 'ta
toolbarScope.disabled = true;
toolbarScope.focussed = false;
});
scope.focussed = false;
},
updateSelectedStyles: function(selectedElement){
// update the active state of all buttons on liked toolbars
Expand Down

0 comments on commit a5200e3

Please sign in to comment.