mirror of https://github.com/ElemeFE/element
support focus and blur for select
parent
c1829e69f1
commit
b1860f5274
|
@ -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 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
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', () => {
|
||||||
}, 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue