From 0a2f32a53d49cbf0db5eef0f7e24c9fb02e0830d Mon Sep 17 00:00:00 2001 From: pingan1927 Date: Fri, 7 Apr 2017 15:17:01 +0800 Subject: [PATCH] fix input textarea search autofocus bug --- .../__tests__/__snapshots__/demo.test.web.js.snap | 2 +- components/input-item/demo/basic.md | 2 +- components/input-item/index.web.tsx | 4 ++-- .../__tests__/__snapshots__/demo.test.web.js.snap | 6 +++--- components/search-bar/demo/basic.md | 4 ++-- components/search-bar/index.web.tsx | 14 +++++++------- .../__tests__/__snapshots__/demo.test.web.js.snap | 2 +- components/textarea-item/demo/basic.md | 2 +- components/textarea-item/index.web.tsx | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/components/input-item/__tests__/__snapshots__/demo.test.web.js.snap b/components/input-item/__tests__/__snapshots__/demo.test.web.js.snap index d08a8d6ff0..a854f88108 100644 --- a/components/input-item/__tests__/__snapshots__/demo.test.web.js.snap +++ b/components/input-item/__tests__/__snapshots__/demo.test.web.js.snap @@ -25,7 +25,7 @@ exports[`renders ./components/input-item/demo/basic.md correctly 1`] = ` class="am-input-control" > diff --git a/components/input-item/demo/basic.md b/components/input-item/demo/basic.md index f890218764..1206c0c753 100644 --- a/components/input-item/demo/basic.md +++ b/components/input-item/demo/basic.md @@ -23,7 +23,7 @@ class BasicInputExample extends React.Component { 标题 { } componentDidMount() { - if (this.props.autoFocus || this.state.focused) { + if ((this.props.autoFocus || this.state.focused) && navigator.userAgent.indexOf('AlipayClient') > 0) { (this.refs as any).input.focus(); } } @@ -155,7 +155,7 @@ class InputItem extends React.Component { try { (document.activeElement as any).scrollIntoViewIfNeeded(); } catch (e) { } - }, 0); + }, 100); } } diff --git a/components/search-bar/__tests__/__snapshots__/demo.test.web.js.snap b/components/search-bar/__tests__/__snapshots__/demo.test.web.js.snap index 8af880dbfc..e0c22c13b9 100644 --- a/components/search-bar/__tests__/__snapshots__/demo.test.web.js.snap +++ b/components/search-bar/__tests__/__snapshots__/demo.test.web.js.snap @@ -59,7 +59,7 @@ exports[`renders ./components/search-bar/demo/basic.md correctly 1`] = `
- 自动获取光标 + 自动获取光标,支付宝客户端有效
- 自动获取光标 + 自动获取光标,支付宝客户端有效 diff --git a/components/search-bar/demo/basic.md b/components/search-bar/demo/basic.md index c1ebfb8149..2b0579921b 100644 --- a/components/search-bar/demo/basic.md +++ b/components/search-bar/demo/basic.md @@ -24,8 +24,8 @@ class SearchBarExample extends React.Component {
普通
-
自动获取光标
- +
自动获取光标,支付宝客户端有效
+
手动获取获取光标
0) { (this.refs as any).searchInput.focus(); } this.componentDidUpdate(); @@ -112,7 +112,7 @@ export default class SearchBar extends React.Component