diff --git a/modules/lib/d3.combobox.js b/modules/lib/d3.combobox.js index a33ba9e1c..c424b797c 100644 --- a/modules/lib/d3.combobox.js +++ b/modules/lib/d3.combobox.js @@ -211,6 +211,9 @@ export function d3combobox() { idx = -1; if (!v) return; + // Don't autocomplete if user is typing a number - #4935 + if (!isNaN(parseFloat(v)) && isFinite(v)) return; + var best = -1; var suggestion, compare; diff --git a/test/spec/lib/d3.combobox.js b/test/spec/lib/d3.combobox.js index 7cc633ca5..9a803f004 100644 --- a/test/spec/lib/d3.combobox.js +++ b/test/spec/lib/d3.combobox.js @@ -160,6 +160,18 @@ describe('d3.combobox', function() { expect(body.selectAll('.combobox-option.selected').text()).to.equal('foo'); // skip foobar }); + it('does not autocomplete numeric options', function() { + var numeric = [ + {title: '100', value: '100'}, + {title: '110', value: '110'} + ]; + input.call(combobox.data(numeric)); + focusTypeahead(input); + simulateKeypress('1'); + simulateKeypress('0'); + expect(body.selectAll('.combobox-option.selected').size()).to.equal(0); + }); + it('selects the completed portion of the value', function() { input.call(combobox.data(data)); focusTypeahead(input);