mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Field): adjust textarea size when focus/blur (#9719)
This commit is contained in:
parent
789e352726
commit
74a136f90e
@ -297,9 +297,17 @@ export default defineComponent({
|
|||||||
const blur = () => inputRef.value?.blur();
|
const blur = () => inputRef.value?.blur();
|
||||||
const focus = () => inputRef.value?.focus();
|
const focus = () => inputRef.value?.focus();
|
||||||
|
|
||||||
|
const adjustTextareaSize = () => {
|
||||||
|
const input = inputRef.value;
|
||||||
|
if (props.type === 'textarea' && props.autosize && input) {
|
||||||
|
resizeTextarea(input, props.autosize);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onFocus = (event: Event) => {
|
const onFocus = (event: Event) => {
|
||||||
state.focused = true;
|
state.focused = true;
|
||||||
emit('focus', event);
|
emit('focus', event);
|
||||||
|
nextTick(adjustTextareaSize);
|
||||||
|
|
||||||
// readonly not work in legacy mobile safari
|
// readonly not work in legacy mobile safari
|
||||||
const readonly = getProp('readonly');
|
const readonly = getProp('readonly');
|
||||||
@ -313,6 +321,7 @@ export default defineComponent({
|
|||||||
updateValue(getModelValue(), 'onBlur');
|
updateValue(getModelValue(), 'onBlur');
|
||||||
emit('blur', event);
|
emit('blur', event);
|
||||||
validateWithTrigger('onBlur');
|
validateWithTrigger('onBlur');
|
||||||
|
nextTick(adjustTextareaSize);
|
||||||
resetScroll();
|
resetScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -364,13 +373,6 @@ export default defineComponent({
|
|||||||
emit('keypress', event);
|
emit('keypress', event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const adjustTextareaSize = () => {
|
|
||||||
const input = inputRef.value;
|
|
||||||
if (props.type === 'textarea' && props.autosize && input) {
|
|
||||||
resizeTextarea(input, props.autosize);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderInput = () => {
|
const renderInput = () => {
|
||||||
const controlClass = bem('control', [
|
const controlClass = bem('control', [
|
||||||
getProp('inputAlign'),
|
getProp('inputAlign'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user