diff --git a/js/lib/d3.combobox.js b/js/lib/d3.combobox.js index 66229aa69..7a5473472 100644 --- a/js/lib/d3.combobox.js +++ b/js/lib/d3.combobox.js @@ -44,11 +44,12 @@ d3.combobox = function() { d3.event.stopPropagation(); d3.event.preventDefault(); input.node().focus(); + fetch('', render); }); }); function focus() { - fetch(render); + fetch(value(), render); } function blur() { @@ -138,7 +139,7 @@ d3.combobox = function() { } function change() { - fetch(function() { + fetch(value(), function() { autocomplete(); render(); }); @@ -163,8 +164,8 @@ d3.combobox = function() { return value; } - function fetch(cb) { - fetcher.call(input, value(), function(_) { + function fetch(v, cb) { + fetcher.call(input, v, function(_) { suggestions = _; cb(); }); diff --git a/test/spec/lib/d3.combobox.js b/test/spec/lib/d3.combobox.js index 8acf0c891..e048e1082 100644 --- a/test/spec/lib/d3.combobox.js +++ b/test/spec/lib/d3.combobox.js @@ -95,6 +95,13 @@ describe("d3.combobox", function() { expect(body.selectAll('.combobox-option').size()).to.equal(0); }); + it("shows all entries when clicking on the caret", function() { + input.property('value', 'foo').call(combobox.data(data)); + happen.mousedown(body.selectAll('.combobox-caret').node()); + expect(body.selectAll('.combobox-option').size()).to.equal(3); + expect(body.selectAll('.combobox-option').text()).to.equal('foo'); + }); + it("is initially shown with no selection", function() { input.call(combobox.data(data)); input.node().focus();