From fd346d17904b5217ca044db24e1060b3c5856c1f Mon Sep 17 00:00:00 2001 From: MinRK Date: Thu, 13 Feb 2014 10:51:33 -0800 Subject: [PATCH] fix remove event in KeyboardManager.register_events only call enable on remove when focused. fixes a bug where command mode could be entered inappropriately when non-focused elements are removed from the page (see first `@interact` example). --- IPython/html/static/notebook/js/keyboardmanager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index a6df32a16..07703b9ac 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -752,9 +752,11 @@ var IPython = (function (IPython) { }); // There are times (raw_input) where we remove the element from the DOM before // focusout is called. In this case we bind to the remove event of jQueryUI, - // which gets triggered upon removal. + // which gets triggered upon removal, iff it is focused at the time. e.on('remove', function () { - that.enable(); + if (document.activeElement === e[0]) { + that.enable(); + } }); }