From 5cb1be1047e2687c0cd878651d30492923936f4e Mon Sep 17 00:00:00 2001 From: tikiatua Date: Sun, 20 Jul 2014 14:04:02 +0200 Subject: [PATCH] Prevent digest cycle problem on enter/tab Wrap function calls in the _onKeyDown function in $timeout to prevent problems with the digest cycle after selecting an item using the keyboard (i.e. tab or enter). --- src/select.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/select.js b/src/select.js index bc0d815e5..77ad6867c 100644 --- a/src/select.js +++ b/src/select.js @@ -271,10 +271,18 @@ break; case Key.Tab: case Key.Enter: - ctrl.select(ctrl.items[ctrl.activeIndex]); + // wrapping the select call in a $timeout will + // ensure that it will run after the current digest cycle is finished + $timeout(function(){ + ctrl.select(ctrl.items[ctrl.activeIndex]); + }); break; case Key.Escape: - ctrl.close(); + // wrapping the select call in a $timeout will + // ensure that it will run after the current digest cycle is finished + $timeout(function(){ + ctrl.close(); + }); break; default: processed = false;