mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-07 07:12:23 +03:00
fix: existing options should be selected with taggable (#1124)
Closes #1121
This commit is contained in:
@@ -56,16 +56,18 @@ export default {
|
||||
* Optionally clear the search input on selection.
|
||||
* @return {void}
|
||||
*/
|
||||
typeAheadSelect () {
|
||||
if (!this.taggable && this.filteredOptions[this.typeAheadPointer]) {
|
||||
this.select(this.filteredOptions[this.typeAheadPointer]);
|
||||
typeAheadSelect() {
|
||||
const typeAheadOption = this.filteredOptions[this.typeAheadPointer];
|
||||
|
||||
if (typeAheadOption) {
|
||||
this.select(typeAheadOption);
|
||||
} else if (this.taggable && this.search.length) {
|
||||
this.select(this.createOption(this.search));
|
||||
}
|
||||
|
||||
if (this.clearSearchOnSelect) {
|
||||
this.search = '';
|
||||
this.search = "";
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { searchSubmit, selectWithProps } from "../helpers";
|
||||
import { mountDefault, searchSubmit, selectWithProps } from '../helpers';
|
||||
import Select from '../../src/components/Select';
|
||||
|
||||
describe("When Tagging Is Enabled", () => {
|
||||
@@ -243,4 +243,17 @@ describe("When Tagging Is Enabled", () => {
|
||||
expect(Select.vm.selectedValue).toEqual([{ label: "one" }]);
|
||||
expect(Select.vm.search).toEqual("");
|
||||
});
|
||||
|
||||
it("will select an existing option on tab", async () => {
|
||||
const Select = mountDefault({
|
||||
taggable: true,
|
||||
selectOnTab: true
|
||||
});
|
||||
|
||||
Select.vm.typeAheadPointer = 0;
|
||||
Select.find({ ref: "search" }).trigger("keydown.tab");
|
||||
|
||||
await Select.vm.$nextTick();
|
||||
expect(Select.vm.selectedValue).toEqual(['one']);
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user