From 2190b3402841e4ba0afea52c3262753eb2525977 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 23 Apr 2019 19:32:33 +0800 Subject: [PATCH] [bugfix] Field: add hack for iOS 12 scroll position (#3204) --- packages/field/index.js | 9 ++++++++- packages/sku/components/SkuMessages.js | 12 +----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/field/index.js b/packages/field/index.js index 3b7d0fa22..485254359 100644 --- a/packages/field/index.js +++ b/packages/field/index.js @@ -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() { diff --git a/packages/sku/components/SkuMessages.js b/packages/sku/components/SkuMessages.js index 63931cdaa..22fdabebc 100644 --- a/packages/sku/components/SkuMessages.js +++ b/packages/sku/components/SkuMessages.js @@ -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} /> )))}