{"action":"created","comment":{"url":"https://api.github.com/repos/react-component/menu/pulls/comments/182644214","pull_request_review_id":113479368,"id":182644214,"diff_hunk":"@@ -65,60 +211,137 @@ const SubPopupMenu = createReactClass({\n     return this.props.openTransitionName;\n   },\n \n+  renderCommonMenuItem(child, i, extraProps) {\n+    const state = this.getStore().getState();\n+    const props = this.props;\n+    const key = getKeyFromChildrenIndex(child, props.eventKey, i);\n+    const childProps = child.props;\n+    const isActive = key === state.activeKey;\n+    const newChildProps = {\n+      mode: props.mode,\n+      level: props.level,\n+      inlineIndent: props.inlineIndent,\n+      renderMenuItem: this.renderMenuItem,\n+      rootPrefixCls: props.prefixCls,\n+      index: i,\n+      parentMenu: props.parentMenu,\n+      // customized ref function, need to be invoked manually in child's componentDidMount\n+      manualRef: childProps.disabled ? undefined :\n+        createChainedFunction(child.ref, saveRef.bind(this, i)),\n+      eventKey: key,\n+      active: !childProps.disabled && isActive,\n+      multiple: props.multiple,\n+      onClick: this.onClick,\n+      onItemHover: this.onItemHover,\n+      openTransitionName: this.getOpenTransitionName(),\n+      openAnimation: props.openAnimation,\n+      subMenuOpenDelay: props.subMenuOpenDelay,\n+      subMenuCloseDelay: props.subMenuCloseDelay,\n+      forceSubMenuRender: props.forceSubMenuRender,\n+      onOpenChange: this.onOpenChange,\n+      onDeselect: this.onDeselect,\n+      onSelect: this.onSelect,\n+      ...extraProps,\n+    };\n+    if (props.mode === 'inline') {\n+      newChildProps.triggerSubMenuAction = 'click';\n+    }\n+    return React.cloneElement(child, newChildProps);\n+  },\n+\n   renderMenuItem(c, i, subMenuKey) {\n-    /* istanbul ignore next */\n+    /* istanbul ignore if */\n     if (!c) {\n       return null;\n     }\n-    const props = this.props;\n+    const state = this.getStore().getState();\n     const extraProps = {\n-      openKeys: props.openKeys,\n-      selectedKeys: props.selectedKeys,\n-      triggerSubMenuAction: props.triggerSubMenuAction,\n+      openKeys: state.openKeys,\n+      selectedKeys: state.selectedKeys,\n+      triggerSubMenuAction: this.props.triggerSubMenuAction,\n       subMenuKey,\n     };\n     return this.renderCommonMenuItem(c, i, extraProps);\n   },\n \n   render() {\n-    const props = { ...this.props };\n-    const haveRendered = this.haveRendered;\n-    this.haveRendered = true;\n-\n-    this.haveOpened = this.haveOpened || props.visible || props.forceSubMenuRender;\n-    // never rendered not planning to, don't render\n-    if (!this.haveOpened) {\n-      return null;\n+    const props = this.props;\n+    this.instanceArray = [];\n+    const className = classNames(\n+      props.prefixCls,\n+      props.className,\n+      `${props.prefixCls}-${props.mode}`,\n+    );\n+    const domProps = {\n+      className,\n+      role: 'menu',\n+      'aria-activedescendant': '',\n+    };\n+    if (props.id) {\n+      domProps.id = props.id;\n     }\n-\n-    // don't show transition on first rendering (no animation for opened menu)\n-    // show appear transition if it's not visible (not sure why)\n-    // show appear transition if it's not inline mode\n-    const transitionAppear = haveRendered || !props.visible || !props.mode === 'inline';\n-\n-    props.className += ` ${props.prefixCls}-sub`;\n-    const animProps = {};\n-\n-    if (props.openTransitionName) {\n-      animProps.transitionName = props.openTransitionName;\n-    } else if (typeof props.openAnimation === 'object') {\n-      animProps.animation = { ...props.openAnimation };\n-      if (!transitionAppear) {\n-        delete animProps.animation.appear;\n-      }\n+    if (props.focusable) {\n+      domProps.tabIndex = '0';\n+      domProps.onKeyDown = this.onKeyDown;\n     }\n-\n     return (\n-      <Animate\n-        {...animProps}\n-        showProp=\"visible\"\n-        component=\"\"\n-        transitionAppear={transitionAppear}\n+      // ESLint is not smart enough to know that the type of `children` was checked.\n+      /* eslint-disable */\n+      <DOMWrap\n+        style={props.style}\n+        tag=\"ul\"\n+        hiddenClassName={`${props.prefixCls}-hidden`}\n+        visible={props.visible}\n+        {...domProps}\n       >\n-        {this.renderRoot(props)}\n-      </Animate>\n+        {React.Children.map(\n+          props.children,\n+          (c, i) => this.renderMenuItem(c, i, props.eventKey || '0-menu-'),\n+        )}\n+      </DOMWrap>\n+      /*eslint-enable */\n     );\n   },\n+\n+  step(direction) {\n+    let children = this.getFlatInstanceArray();\n+    const activeKey = this.getStore().getState().activeKey[this.getEventKey()];\n+    const len = children.length;\n+    if (!len) {\n+      return null;\n+    }\n+    if (direction < 0) {\n+      children = children.concat().reverse();\n+    }\n+    // find current activeIndex\n+    let activeIndex = -1;\n+    children.every((c, ci) => {\n+      if (c && c.props.eventKey === activeKey) {\n+        activeIndex = ci;\n+        return false;\n+      }\n+      return true;\n+    });\n+    if (!this.props.defaultActiveFirst && activeIndex !== -1) {\n+      if (allDisabled(children.slice(activeIndex, len - 1))) {","path":"src/SubPopupMenu.js","position":331,"original_position":331,"commit_id":"8529ac3cc2c76d549b14334ebb78be0e54c0b1d5","original_commit_id":"8529ac3cc2c76d549b14334ebb78be0e54c0b1d5","user":{"login":"afc163","id":507615,"avatar_url":"https://avatars1.githubusercontent.com/u/507615?v=4","gravatar_id":"","url":"https://api.github.com/users/afc163","html_url":"https://github.com/afc163","followers_url":"https://api.github.com/users/afc163/followers","following_url":"https://api.github.com/users/afc163/following{/other_user}","gists_url":"https://api.github.com/users/afc163/gists{/gist_id}","starred_url":"https://api.github.com/users/afc163/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afc163/subscriptions","organizations_url":"https://api.github.com/users/afc163/orgs","repos_url":"https://api.github.com/users/afc163/repos","events_url":"https://api.github.com/users/afc163/events{/privacy}","received_events_url":"https://api.github.com/users/afc163/received_events","type":"User","site_admin":false},"body":"这两个 if 可以合并。","created_at":"2018-04-19T06:27:59Z","updated_at":"2018-04-19T06:27:59Z","html_url":"https://github.com/react-component/menu/pull/133#discussion_r182644214","pull_request_url":"https://api.github.com/repos/react-component/menu/pulls/133","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/react-component/menu/pulls/comments/182644214"},"html":{"href":"https://github.com/react-component/menu/pull/133#discussion_r182644214"},"pull_request":{"href":"https://api.github.com/repos/react-component/menu/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/react-component/menu/pulls/133","id":182484262,"html_url":"https://github.com/react-component/menu/pull/133","diff_url":"https://github.com/react-component/menu/pull/133.diff","patch_url":"https://github.com/react-component/menu/pull/133.patch","issue_url":"https://api.github.com/repos/react-component/menu/issues/133","number":133,"state":"open","locked":false,"title":"[WIP]chore: refactor/remove mixin","user":{"login":"picodoth","id":1731837,"avatar_url":"https://avatars0.githubusercontent.com/u/1731837?v=4","gravatar_id":"","url":"https://api.github.com/users/picodoth","html_url":"https://github.com/picodoth","followers_url":"https://api.github.com/users/picodoth/followers","following_url":"https://api.github.com/users/picodoth/following{/other_user}","gists_url":"https://api.github.com/users/picodoth/gists{/gist_id}","starred_url":"https://api.github.com/users/picodoth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picodoth/subscriptions","organizations_url":"https://api.github.com/users/picodoth/orgs","repos_url":"https://api.github.com/users/picodoth/repos","events_url":"https://api.github.com/users/picodoth/events{/privacy}","received_events_url":"https://api.github.com/users/picodoth/received_events","type":"User","site_admin":false},"body":"- [ ] Handle menu.onKeyDown usage in rc-select","created_at":"2018-04-18T13:45:44Z","updated_at":"2018-04-19T06:27:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ad72d7b019bff1076de838ba46b3f75a704eb096","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yesmeck","id":465125,"avatar_url":"https://avatars0.githubusercontent.com/u/465125?v=4","gravatar_id":"","url":"https://api.github.com/users/yesmeck","html_url":"https://github.com/yesmeck","followers_url":"https://api.github.com/users/yesmeck/followers","following_url":"https://api.github.com/users/yesmeck/following{/other_user}","gists_url":"https://api.github.com/users/yesmeck/gists{/gist_id}","starred_url":"https://api.github.com/users/yesmeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yesmeck/subscriptions","organizations_url":"https://api.github.com/users/yesmeck/orgs","repos_url":"https://api.github.com/users/yesmeck/repos","events_url":"https://api.github.com/users/yesmeck/events{/privacy}","received_events_url":"https://api.github.com/users/yesmeck/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/react-component/menu/pulls/133/commits","review_comments_url":"https://api.github.com/repos/react-component/menu/pulls/133/comments","review_comment_url":"https://api.github.com/repos/react-component/menu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/react-component/menu/issues/133/comments","statuses_url":"https://api.github.com/repos/react-component/menu/statuses/8529ac3cc2c76d549b14334ebb78be0e54c0b1d5","head":{"label":"react-component:rm-mixin","ref":"rm-mixin","sha":"8529ac3cc2c76d549b14334ebb78be0e54c0b1d5","user":{"login":"react-component","id":9441414,"avatar_url":"https://avatars0.githubusercontent.com/u/9441414?v=4","gravatar_id":"","url":"https://api.github.com/users/react-component","html_url":"https://github.com/react-component","followers_url":"https://api.github.com/users/react-component/followers","following_url":"https://api.github.com/users/react-component/following{/other_user}","gists_url":"https://api.github.com/users/react-component/gists{/gist_id}","starred_url":"https://api.github.com/users/react-component/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-component/subscriptions","organizations_url":"https://api.github.com/users/react-component/orgs","repos_url":"https://api.github.com/users/react-component/repos","events_url":"https://api.github.com/users/react-component/events{/privacy}","received_events_url":"https://api.github.com/users/react-component/received_events","type":"Organization","site_admin":false},"repo":{"id":28470877,"name":"menu","full_name":"react-component/menu","owner":{"login":"react-component","id":9441414,"avatar_url":"https://avatars0.githubusercontent.com/u/9441414?v=4","gravatar_id":"","url":"https://api.github.com/users/react-component","html_url":"https://github.com/react-component","followers_url":"https://api.github.com/users/react-component/followers","following_url":"https://api.github.com/users/react-component/following{/other_user}","gists_url":"https://api.github.com/users/react-component/gists{/gist_id}","starred_url":"https://api.github.com/users/react-component/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-component/subscriptions","organizations_url":"https://api.github.com/users/react-component/orgs","repos_url":"https://api.github.com/users/react-component/repos","events_url":"https://api.github.com/users/react-component/events{/privacy}","received_events_url":"https://api.github.com/users/react-component/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/react-component/menu","description":"React Menu","fork":false,"url":"https://api.github.com/repos/react-component/menu","forks_url":"https://api.github.com/repos/react-component/menu/forks","keys_url":"https://api.github.com/repos/react-component/menu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/react-component/menu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/react-component/menu/teams","hooks_url":"https://api.github.com/repos/react-component/menu/hooks","issue_events_url":"https://api.github.com/repos/react-component/menu/issues/events{/number}","events_url":"https://api.github.com/repos/react-component/menu/events","assignees_url":"https://api.github.com/repos/react-component/menu/assignees{/user}","branches_url":"https://api.github.com/repos/react-component/menu/branches{/branch}","tags_url":"https://api.github.com/repos/react-component/menu/tags","blobs_url":"https://api.github.com/repos/react-component/menu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/react-component/menu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/react-component/menu/git/refs{/sha}","trees_url":"https://api.github.com/repos/react-component/menu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/react-component/menu/statuses/{sha}","languages_url":"https://api.github.com/repos/react-component/menu/languages","stargazers_url":"https://api.github.com/repos/react-component/menu/stargazers","contributors_url":"https://api.github.com/repos/react-component/menu/contributors","subscribers_url":"https://api.github.com/repos/react-component/menu/subscribers","subscription_url":"https://api.github.com/repos/react-component/menu/subscription","commits_url":"https://api.github.com/repos/react-component/menu/commits{/sha}","git_commits_url":"https://api.github.com/repos/react-component/menu/git/commits{/sha}","comments_url":"https://api.github.com/repos/react-component/menu/comments{/number}","issue_comment_url":"https://api.github.com/repos/react-component/menu/issues/comments{/number}","contents_url":"https://api.github.com/repos/react-component/menu/contents/{+path}","compare_url":"https://api.github.com/repos/react-component/menu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/react-component/menu/merges","archive_url":"https://api.github.com/repos/react-component/menu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/react-component/menu/downloads","issues_url":"https://api.github.com/repos/react-component/menu/issues{/number}","pulls_url":"https://api.github.com/repos/react-component/menu/pulls{/number}","milestones_url":"https://api.github.com/repos/react-component/menu/milestones{/number}","notifications_url":"https://api.github.com/repos/react-component/menu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/react-component/menu/labels{/name}","releases_url":"https://api.github.com/repos/react-component/menu/releases{/id}","deployments_url":"https://api.github.com/repos/react-component/menu/deployments","created_at":"2014-12-25T04:36:57Z","updated_at":"2018-04-19T04:23:45Z","pushed_at":"2018-04-19T06:14:24Z","git_url":"git://github.com/react-component/menu.git","ssh_url":"git@github.com:react-component/menu.git","clone_url":"https://github.com/react-component/menu.git","svn_url":"https://github.com/react-component/menu","homepage":"http://react-component.github.io/menu/","size":8425,"stargazers_count":253,"watchers_count":253,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":77,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":77,"open_issues":14,"watchers":253,"default_branch":"master"}},"base":{"label":"react-component:master","ref":"master","sha":"6eb19f0bbbfbf93b8392558253f53e280bdcd33e","user":{"login":"react-component","id":9441414,"avatar_url":"https://avatars0.githubusercontent.com/u/9441414?v=4","gravatar_id":"","url":"https://api.github.com/users/react-component","html_url":"https://github.com/react-component","followers_url":"https://api.github.com/users/react-component/followers","following_url":"https://api.github.com/users/react-component/following{/other_user}","gists_url":"https://api.github.com/users/react-component/gists{/gist_id}","starred_url":"https://api.github.com/users/react-component/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-component/subscriptions","organizations_url":"https://api.github.com/users/react-component/orgs","repos_url":"https://api.github.com/users/react-component/repos","events_url":"https://api.github.com/users/react-component/events{/privacy}","received_events_url":"https://api.github.com/users/react-component/received_events","type":"Organization","site_admin":false},"repo":{"id":28470877,"name":"menu","full_name":"react-component/menu","owner":{"login":"react-component","id":9441414,"avatar_url":"https://avatars0.githubusercontent.com/u/9441414?v=4","gravatar_id":"","url":"https://api.github.com/users/react-component","html_url":"https://github.com/react-component","followers_url":"https://api.github.com/users/react-component/followers","following_url":"https://api.github.com/users/react-component/following{/other_user}","gists_url":"https://api.github.com/users/react-component/gists{/gist_id}","starred_url":"https://api.github.com/users/react-component/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-component/subscriptions","organizations_url":"https://api.github.com/users/react-component/orgs","repos_url":"https://api.github.com/users/react-component/repos","events_url":"https://api.github.com/users/react-component/events{/privacy}","received_events_url":"https://api.github.com/users/react-component/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/react-component/menu","description":"React Menu","fork":false,"url":"https://api.github.com/repos/react-component/menu","forks_url":"https://api.github.com/repos/react-component/menu/forks","keys_url":"https://api.github.com/repos/react-component/menu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/react-component/menu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/react-component/menu/teams","hooks_url":"https://api.github.com/repos/react-component/menu/hooks","issue_events_url":"https://api.github.com/repos/react-component/menu/issues/events{/number}","events_url":"https://api.github.com/repos/react-component/menu/events","assignees_url":"https://api.github.com/repos/react-component/menu/assignees{/user}","branches_url":"https://api.github.com/repos/react-component/menu/branches{/branch}","tags_url":"https://api.github.com/repos/react-component/menu/tags","blobs_url":"https://api.github.com/repos/react-component/menu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/react-component/menu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/react-component/menu/git/refs{/sha}","trees_url":"https://api.github.com/repos/react-component/menu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/react-component/menu/statuses/{sha}","languages_url":"https://api.github.com/repos/react-component/menu/languages","stargazers_url":"https://api.github.com/repos/react-component/menu/stargazers","contributors_url":"https://api.github.com/repos/react-component/menu/contributors","subscribers_url":"https://api.github.com/repos/react-component/menu/subscribers","subscription_url":"https://api.github.com/repos/react-component/menu/subscription","commits_url":"https://api.github.com/repos/react-component/menu/commits{/sha}","git_commits_url":"https://api.github.com/repos/react-component/menu/git/commits{/sha}","comments_url":"https://api.github.com/repos/react-component/menu/comments{/number}","issue_comment_url":"https://api.github.com/repos/react-component/menu/issues/comments{/number}","contents_url":"https://api.github.com/repos/react-component/menu/contents/{+path}","compare_url":"https://api.github.com/repos/react-component/menu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/react-component/menu/merges","archive_url":"https://api.github.com/repos/react-component/menu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/react-component/menu/downloads","issues_url":"https://api.github.com/repos/react-component/menu/issues{/number}","pulls_url":"https://api.github.com/repos/react-component/menu/pulls{/number}","milestones_url":"https://api.github.com/repos/react-component/menu/milestones{/number}","notifications_url":"https://api.github.com/repos/react-component/menu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/react-component/menu/labels{/name}","releases_url":"https://api.github.com/repos/react-component/menu/releases{/id}","deployments_url":"https://api.github.com/repos/react-component/menu/deployments","created_at":"2014-12-25T04:36:57Z","updated_at":"2018-04-19T04:23:45Z","pushed_at":"2018-04-19T06:14:24Z","git_url":"git://github.com/react-component/menu.git","ssh_url":"git@github.com:react-component/menu.git","clone_url":"https://github.com/react-component/menu.git","svn_url":"https://github.com/react-component/menu","homepage":"http://react-component.github.io/menu/","size":8425,"stargazers_count":253,"watchers_count":253,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":77,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":77,"open_issues":14,"watchers":253,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/react-component/menu/pulls/133"},"html":{"href":"https://github.com/react-component/menu/pull/133"},"issue":{"href":"https://api.github.com/repos/react-component/menu/issues/133"},"comments":{"href":"https://api.github.com/repos/react-component/menu/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/react-component/menu/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/react-component/menu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/react-component/menu/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/react-component/menu/statuses/8529ac3cc2c76d549b14334ebb78be0e54c0b1d5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"afc163"}}