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

support focus and blur for select

parent c1829e69
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
:readonly="!filterable || multiple" :readonly="!filterable || multiple"
:validate-event="false" :validate-event="false"
@focus="handleFocus" @focus="handleFocus"
@blur="handleBlur"
@click="handleIconClick" @click="handleIconClick"
@mousedown.native="handleMouseDown" @mousedown.native="handleMouseDown"
@keyup.native="debouncedOnInputChange" @keyup.native="debouncedOnInputChange"
...@@ -426,8 +427,13 @@ ...@@ -426,8 +427,13 @@
}); });
}, },
handleFocus() { handleFocus(event) {
this.visible = true; this.visible = true;
this.$emit('focus', event);
},
handleBlur(event) {
this.$emit('blur', event);
}, },
handleIconClick(event) { handleIconClick(event) {
......
...@@ -607,4 +607,26 @@ describe('Select', () => { ...@@ -607,4 +607,26 @@ describe('Select', () => {
}, 250); }, 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