Prefer suggested capitalization over user value in combobox (closes #2791)

This commit is contained in:
Bryan Housel
2015-10-17 23:17:17 -04:00
parent 084825bfe2
commit 66e8f78aa7
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ d3.combobox = function() {
for (var i = 0; i < suggestions.length; i++) {
if (suggestions[i].value.toLowerCase().indexOf(v.toLowerCase()) === 0) {
var completion = v + suggestions[i].value.substr(v.length);
var completion = suggestions[i].value;
idx = i;
input.property('value', completion);
input.node().setSelectionRange(v.length, completion.length);
+2 -2
View File
@@ -132,11 +132,11 @@ describe("d3.combobox", function() {
expect(input.property('selectionEnd')).to.equal(3);
});
it("preserves the case of the input portion of the value", function() {
it("does not preserve the case of the input portion of the value", function() {
input.call(combobox.data(data));
input.node().focus();
simulateKeypress('B');
expect(input.property('value')).to.equal('Bar');
expect(input.property('value')).to.equal('bar');
expect(input.property('selectionStart')).to.equal(1);
expect(input.property('selectionEnd')).to.equal(3);
});