From 6f1f84aa6225153e63f3c5a9ab04a105c1e75480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 24 Aug 2014 18:13:24 +0100 Subject: [PATCH] Prevent triggering ng-focus on input during completion $apply during another $apply is not possible, and .focus() on the input node triggers the ng-focus on it (which hides the sidebar, if on mobile), so to prevent the exception from being thrown, move the input node focusing out of the $apply with a timeout of 0. --- js/glowingbear.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index a995baa..d7e6500 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1428,8 +1428,10 @@ weechat.directive('inputBar', function() { $scope.command = nickComp.text; // update current caret position - inputNode.focus(); - inputNode.setSelectionRange(nickComp.caretPos, nickComp.caretPos); + setTimeout(function() { + inputNode.focus(); + inputNode.setSelectionRange(nickComp.caretPos, nickComp.caretPos); + }, 0); };