[bugfix] Field: add hack for iOS 12 scroll position (#3204)

This commit is contained in:
neverland 2019-04-23 19:32:33 +08:00 committed by GitHub
parent 5f2b027070
commit 2190b34028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -1,4 +1,4 @@
import { use, isObj, isDef } from '../utils';
import { use, isObj, isDef, isIOS } from '../utils';
import Icon from '../icon';
import Cell from '../cell';
import { cellProps } from '../cell/shared';
@ -102,6 +102,13 @@ export default sfc({
onBlur(event) {
this.focused = false;
this.$emit('blur', event);
// Hack for iOS12 page scroll
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
/* istanbul ignore next */
if (isIOS()) {
window.scrollTo(0, window.pageYOffset);
}
},
onClickLeftIcon() {

View File

@ -1,4 +1,4 @@
import { use, isIOS } from '../../utils';
import { use } from '../../utils';
import Cell from '../../cell';
import CellGroup from '../../cell-group';
import Field from '../../field';
@ -118,15 +118,6 @@ export default sfc({
}
}
}
},
onBlur() {
// 修复 ios12 键盘弹起后点击错位的问题
// https://developers.weixin.qq.com/community/develop/doc/00044ae90742f8c82fb78fcae56800
/* istanbul ignore next */
if (isIOS()) {
window.scrollTo(0, 0);
}
}
},
@ -156,7 +147,6 @@ export default sfc({
required={String(message.required) === '1'}
placeholder={this.getPlaceholder(message)}
type={this.getType(message)}
onBlur={this.onBlur}
/>
)))}
</CellGroup>