mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Stepper): should not emit focus when input is readonly
This commit is contained in:
parent
7327a481d1
commit
c6024b18b4
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -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', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user