mirror of https://github.com/ElemeFE/element
Select: fix filterable init value issue, fixed #2196
parent
68c1c84875
commit
3b5248ec2a
|
@ -387,6 +387,7 @@
|
||||||
}
|
}
|
||||||
this.selectedLabel = option.currentLabel;
|
this.selectedLabel = option.currentLabel;
|
||||||
this.selected = option;
|
this.selected = option;
|
||||||
|
if (this.filterable) this.query = this.selectedLabel;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
|
@ -48,6 +48,7 @@ describe('Select', () => {
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
|
:key="item.value"
|
||||||
:disabled="item.disabled"
|
:disabled="item.disabled"
|
||||||
:value="item.value">
|
:value="item.value">
|
||||||
</el-option>
|
</el-option>
|
||||||
|
@ -373,13 +374,15 @@ describe('Select', () => {
|
||||||
it('filterable', done => {
|
it('filterable', done => {
|
||||||
vm = getSelectVm({ filterable: true });
|
vm = getSelectVm({ filterable: true });
|
||||||
const select = vm.$children[0];
|
const select = vm.$children[0];
|
||||||
|
setTimeout(() => {
|
||||||
select.selectedLabel = '面';
|
select.selectedLabel = '面';
|
||||||
select.onInputChange();
|
select.onInputChange();
|
||||||
select.visible = true;
|
select.visible = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(select.filteredOptionsCount).to.equal(1);
|
expect(select.filteredOptionsCount).to.equal(1);
|
||||||
done();
|
done();
|
||||||
}, 100);
|
}, 10);
|
||||||
|
}, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filterable with custom filter-method', done => {
|
it('filterable with custom filter-method', done => {
|
||||||
|
@ -390,19 +393,24 @@ describe('Select', () => {
|
||||||
};
|
};
|
||||||
vm = getSelectVm({ filterable: true, filterMethod });
|
vm = getSelectVm({ filterable: true, filterMethod });
|
||||||
const select = vm.$children[0];
|
const select = vm.$children[0];
|
||||||
select.query = '面';
|
select.$el.querySelector('input').focus();
|
||||||
|
setTimeout(() => {
|
||||||
|
select.selectedLabel = '面';
|
||||||
|
select.onInputChange();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(select.filteredOptionsCount).to.equal(4);
|
expect(select.filteredOptionsCount).to.equal(4);
|
||||||
done();
|
done();
|
||||||
}, 100);
|
}, 10);
|
||||||
|
}, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allow create', done => {
|
it('allow create', done => {
|
||||||
vm = getSelectVm({ filterable: true, allowCreate: true });
|
vm = getSelectVm({ filterable: true, allowCreate: true });
|
||||||
const select = vm.$children[0];
|
const select = vm.$children[0];
|
||||||
|
select.$el.querySelector('input').focus();
|
||||||
|
setTimeout(() => {
|
||||||
select.selectedLabel = 'new';
|
select.selectedLabel = 'new';
|
||||||
select.onInputChange();
|
select.onInputChange();
|
||||||
select.visible = true;
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const options = document.querySelectorAll('.el-select-dropdown__item span');
|
const options = document.querySelectorAll('.el-select-dropdown__item span');
|
||||||
const target = [].filter.call(options, option => option.innerText === 'new');
|
const target = [].filter.call(options, option => option.innerText === 'new');
|
||||||
|
@ -410,8 +418,9 @@ describe('Select', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(select.value.indexOf('new') > -1).to.true;
|
expect(select.value.indexOf('new') > -1).to.true;
|
||||||
done();
|
done();
|
||||||
}, 50);
|
}, 10);
|
||||||
}, 50);
|
}, 10);
|
||||||
|
}, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiple select', done => {
|
it('multiple select', done => {
|
||||||
|
|
Loading…
Reference in New Issue