Don't autocomplete numeric values in the combobox

(closes #4935)
This commit is contained in:
Bryan Housel
2018-03-27 22:15:19 -04:00
parent 734957f283
commit 4840fea0bc
2 changed files with 15 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);