{"action":"created","issue":{"url":"https://api.github.com/repos/ant-design/ant-design/issues/993","repository_url":"https://api.github.com/repos/ant-design/ant-design","labels_url":"https://api.github.com/repos/ant-design/ant-design/issues/993/labels{/name}","comments_url":"https://api.github.com/repos/ant-design/ant-design/issues/993/comments","events_url":"https://api.github.com/repos/ant-design/ant-design/issues/993/events","html_url":"https://github.com/ant-design/ant-design/issues/993","id":131005797,"number":993,"title":"form 自动滚动到出错项","user":{"login":"yiminghe","id":200876,"avatar_url":"https://avatars.githubusercontent.com/u/200876?v=3","gravatar_id":"","url":"https://api.github.com/users/yiminghe","html_url":"https://github.com/yiminghe","followers_url":"https://api.github.com/users/yiminghe/followers","following_url":"https://api.github.com/users/yiminghe/following{/other_user}","gists_url":"https://api.github.com/users/yiminghe/gists{/gist_id}","starred_url":"https://api.github.com/users/yiminghe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yiminghe/subscriptions","organizations_url":"https://api.github.com/users/yiminghe/orgs","repos_url":"https://api.github.com/users/yiminghe/repos","events_url":"https://api.github.com/users/yiminghe/events{/privacy}","received_events_url":"https://api.github.com/users/yiminghe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"benjycui","id":3580607,"avatar_url":"https://avatars.githubusercontent.com/u/3580607?v=3","gravatar_id":"","url":"https://api.github.com/users/benjycui","html_url":"https://github.com/benjycui","followers_url":"https://api.github.com/users/benjycui/followers","following_url":"https://api.github.com/users/benjycui/following{/other_user}","gists_url":"https://api.github.com/users/benjycui/gists{/gist_id}","starred_url":"https://api.github.com/users/benjycui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjycui/subscriptions","organizations_url":"https://api.github.com/users/benjycui/orgs","repos_url":"https://api.github.com/users/benjycui/repos","events_url":"https://api.github.com/users/benjycui/events{/privacy}","received_events_url":"https://api.github.com/users/benjycui/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-02-03T12:10:04Z","updated_at":"2016-02-04T03:51:13Z","closed_at":null,"body":"http://react-component.github.io/form/examples/overview.html\r\n\r\n```js\r\nfunction addScrollToValidate(validateFields) {\r\n  return (...args) => {\r\n    const originalCallback = args[args.length - 1];\r\n\r\n    function newCb(error, values) {\r\n      if (error) {\r\n        for (const name in error) {\r\n          if (error.hasOwnProperty(name) && error[name].instance) {\r\n            scrollIntoView(ReactDOM.findDOMNode(error[name].instance), window, {\r\n              onlyScrollIfNeeded: true,\r\n            });\r\n            break;\r\n          }\r\n        }\r\n      }\r\n      if (typeof originalCallback === 'function') {\r\n        originalCallback(error, values);\r\n      }\r\n    }\r\n\r\n    if (typeof originalCallback === 'function') {\r\n      args[args.length - 1] = newCb;\r\n    } else {\r\n      args.push(newCb);\r\n    }\r\n    validateFields.apply(null, args);\r\n  };\r\n}\r\n\r\n@createForm({\r\n  refComponent: true,\r\n  mapProps(props) {\r\n    if (!this.__scrollAndValidate) {\r\n      this.__scrollAndValidate = addScrollToValidate(props.form.validateFields);\r\n    }\r\n    return {\r\n      ...props,\r\n      scrollAndValidate: this.__scrollAndValidate,\r\n    };\r\n  },\r\n```\r\n\r\n滚动到 submit 点击，自动滚动到 user 处, 封装 validateFields"},"comment":{"url":"https://api.github.com/repos/ant-design/ant-design/issues/comments/179607221","html_url":"https://github.com/ant-design/ant-design/issues/993#issuecomment-179607221","issue_url":"https://api.github.com/repos/ant-design/ant-design/issues/993","id":179607221,"user":{"login":"yiminghe","id":200876,"avatar_url":"https://avatars.githubusercontent.com/u/200876?v=3","gravatar_id":"","url":"https://api.github.com/users/yiminghe","html_url":"https://github.com/yiminghe","followers_url":"https://api.github.com/users/yiminghe/followers","following_url":"https://api.github.com/users/yiminghe/following{/other_user}","gists_url":"https://api.github.com/users/yiminghe/gists{/gist_id}","starred_url":"https://api.github.com/users/yiminghe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yiminghe/subscriptions","organizations_url":"https://api.github.com/users/yiminghe/orgs","repos_url":"https://api.github.com/users/yiminghe/repos","events_url":"https://api.github.com/users/yiminghe/events{/privacy}","received_events_url":"https://api.github.com/users/yiminghe/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T03:51:13Z","updated_at":"2016-02-04T03:51:13Z","body":"改动比较小，下个版本吧"}}