From 68e57a5e646faef82c50f2eae7f156286ec2128c 2014-11-17 18:01:25 From: Min RK Date: 2014-11-17 18:01:25 Subject: [PATCH] Merge pull request #6943 from jdfreder/numtextfix Allow empty text box *while typing* for numeric widgets --- diff --git a/IPython/html/static/widgets/js/widget_int.js b/IPython/html/static/widgets/js/widget_int.js index 3fd0ae0..3cac734 100644 --- a/IPython/html/static/widgets/js/widget_int.js +++ b/IPython/html/static/widgets/js/widget_int.js @@ -335,8 +335,10 @@ define([ // Try to parse value as a int. var numericalValue = 0; - if (e.target.value !== '') { - var trimmed = e.target.value.trim(); + var trimmed = e.target.value.trim(); + if (trimmed === '') { + return; + } else { if (!(['-', '-.', '.', '+.', '+'].indexOf(trimmed) >= 0)) { numericalValue = this._parse_value(e.target.value); } @@ -366,7 +368,7 @@ define([ handleChanged: function(e) { // Applies validated input. - if (this.model.get('value') != e.target.value) { + if (e.target.value.trim() === '' || e.target.value !== this.model.get('value')) { e.target.value = this.model.get('value'); } },