Show all combobox entries when clicking the caret (fixes #1755)

This commit is contained in:
John Firebaugh
2013-10-11 14:37:03 -07:00
parent 04f0806ce2
commit 8c30278d2d
2 changed files with 12 additions and 4 deletions
+5 -4
View File
@@ -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();
});
+7
View File
@@ -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();