Commit b1860f52 authored by Dreamacro's avatar Dreamacro Committed by 杨奕

support focus and blur for select

parent c1829e69
......@@ -51,6 +51,7 @@
:readonly="!filterable || multiple"
:validate-event="false"
@focus="handleFocus"
@blur="handleBlur"
@click="handleIconClick"
@mousedown.native="handleMouseDown"
@keyup.native="debouncedOnInputChange"
......@@ -426,8 +427,13 @@
});
},
handleFocus() {
handleFocus(event) {
this.visible = true;
this.$emit('focus', event);
},
handleBlur(event) {
this.$emit('blur', event);
},
handleIconClick(event) {
......
......@@ -607,4 +607,26 @@ describe('Select', () => {
}, 250);
});
});
it('event:focus & blur', done => {
vm = createVue({
template: `
<el-select ref="select"></el-select>
`
}, true);
const spyFocus = sinon.spy();
const spyBlur = sinon.spy();
vm.$refs.select.$on('focus', spyFocus);
vm.$refs.select.$on('blur', spyBlur);
vm.$el.querySelector('input').focus();
vm.$el.querySelector('input').blur();
vm.$nextTick(_ => {
expect(spyFocus.calledOnce).to.be.true;
expect(spyBlur.calledOnce).to.be.true;
done();
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment