mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-09-05 15:39:46 +08:00
fix(Field): autofocus prop not work (#8488)
This commit is contained in:
parent
60bc702bb8
commit
07431487f3
@ -59,6 +59,7 @@ export const fieldProps = {
|
|||||||
formatter: Function as PropType<(value: string) => string>,
|
formatter: Function as PropType<(value: string) => string>,
|
||||||
leftIcon: String,
|
leftIcon: String,
|
||||||
rightIcon: String,
|
rightIcon: String,
|
||||||
|
autofocus: Boolean,
|
||||||
clearable: Boolean,
|
clearable: Boolean,
|
||||||
maxlength: [Number, String],
|
maxlength: [Number, String],
|
||||||
inputAlign: String as PropType<FieldTextAlign>,
|
inputAlign: String as PropType<FieldTextAlign>,
|
||||||
@ -397,6 +398,7 @@ export default defineComponent({
|
|||||||
value: props.modelValue,
|
value: props.modelValue,
|
||||||
disabled: getProp('disabled'),
|
disabled: getProp('disabled'),
|
||||||
readonly: getProp('readonly'),
|
readonly: getProp('readonly'),
|
||||||
|
autofocus: props.autofocus,
|
||||||
placeholder: props.placeholder,
|
placeholder: props.placeholder,
|
||||||
autocomplete: props.autocomplete,
|
autocomplete: props.autocomplete,
|
||||||
onBlur,
|
onBlur,
|
||||||
|
@ -444,3 +444,14 @@ test('should change clear icon when using clear-icon prop', async () => {
|
|||||||
await input.trigger('focus');
|
await input.trigger('focus');
|
||||||
expect(wrapper.find('.van-field__clear').html()).toMatchSnapshot();
|
expect(wrapper.find('.van-field__clear').html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render autofocus attribute to input when using autofocus prop', async () => {
|
||||||
|
const wrapper = mount(Field, {
|
||||||
|
props: {
|
||||||
|
autofocus: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const input = wrapper.find('input');
|
||||||
|
expect(input.element.hasAttributes('autofocus')).toBeTruthy();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user