fix(Stepper): should not emit focus when input is readonly

This commit is contained in:
chenjiahan 2020-05-09 10:12:34 +08:00
parent 7327a481d1
commit c6024b18b4
2 changed files with 12 additions and 7 deletions

View File

@ -209,11 +209,11 @@ export default createComponent({
},
onFocus(event) {
this.$emit('focus', event);
// readonly not work in lagacy mobile safari
if (this.disableInput && this.$refs.input) {
this.$refs.input.blur();
} else {
this.$emit('focus', event);
}
},

View File

@ -173,14 +173,19 @@ test('input invalid value and blur', () => {
});
test('stepper focus', () => {
const wrapper = mount(Stepper);
const wrapper = mount(Stepper, {
propsData: {
disableInput: true,
},
});
const input = wrapper.find('input');
input.trigger('focus');
expect(wrapper.emitted('focus')).toBeFalsy();
wrapper.setProps({ disableInput: false });
input.trigger('focus');
expect(wrapper.emitted('focus')).toBeTruthy();
wrapper.setProps({ disableInput: true });
input.trigger('focus');
expect(wrapper.emitted('blur')).toBeTruthy();
});
test('stepper blur', () => {