mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Field): textarea scroll to top after resizing (#9207)
This commit is contained in:
parent
824fbb8c6f
commit
405170f5e6
@ -2,6 +2,7 @@
|
||||
import { resetScroll } from '../utils/dom/reset-scroll';
|
||||
import { formatNumber } from '../utils/format/number';
|
||||
import { preventDefault } from '../utils/dom/event';
|
||||
import { getRootScrollTop, setRootScrollTop } from '../utils/dom/scroll';
|
||||
import {
|
||||
isDef,
|
||||
addUnit,
|
||||
@ -347,7 +348,7 @@ export default createComponent({
|
||||
this.focused = true;
|
||||
this.$emit('focus', event);
|
||||
|
||||
// readonly not work in lagacy mobile safari
|
||||
// readonly not work in legacy mobile safari
|
||||
/* istanbul ignore if */
|
||||
const readonly = this.getProp('readonly');
|
||||
if (readonly) {
|
||||
@ -409,6 +410,7 @@ export default createComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollTop = getRootScrollTop();
|
||||
input.style.height = 'auto';
|
||||
|
||||
let height = input.scrollHeight;
|
||||
@ -424,6 +426,8 @@ export default createComponent({
|
||||
|
||||
if (height) {
|
||||
input.style.height = height + 'px';
|
||||
// https://github.com/youzan/vant/issues/9178
|
||||
setRootScrollTop(scrollTop);
|
||||
}
|
||||
},
|
||||
|
||||
@ -475,8 +479,8 @@ export default createComponent({
|
||||
let inputType = type;
|
||||
let inputMode;
|
||||
|
||||
// type="number" is weired in iOS, and can't prevent dot in Android
|
||||
// so use inputmode to set keyboard in mordern browers
|
||||
// type="number" is weird in iOS, and can't prevent dot in Android
|
||||
// so use inputmode to set keyboard in modern browsers
|
||||
if (type === 'number') {
|
||||
inputType = 'text';
|
||||
inputMode = 'decimal';
|
||||
|
Loading…
x
Reference in New Issue
Block a user