-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor/remove mixin #133
Conversation
picodoth
commented
Apr 18, 2018
•
edited
Loading
edited
- Handle menu.onKeyDown usage in rc-select
Remove all createReactClass, use ES class. |
src/SubPopupMenu.js
Outdated
return true; | ||
}); | ||
if (!this.props.defaultActiveFirst && activeIndex !== -1) { | ||
if (allDisabled(children.slice(activeIndex, len - 1))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个 if 可以合并。
src/SubPopupMenu.js
Outdated
} | ||
const start = (activeIndex + 1) % len; | ||
let i = start; | ||
for (; ;) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 while 是不是清晰一点。
src/SubPopupMenu.js
Outdated
if (i === start) { | ||
return null; | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 else 是多余的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是多余的,如果找到一个有效的child就立马返回啊
src/SubPopupMenu.js
Outdated
if (c) { | ||
this.instanceArray[index] = c; | ||
} | ||
} | ||
|
||
const SubPopupMenu = createReactClass({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去掉了 Mixin 就可以用 ES6 class 了。
src/SubPopupMenu.js
Outdated
getStore() { | ||
const store = this.props.store; | ||
|
||
return store; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.props.store
?
}, | ||
}); | ||
|
||
MenuItem.isMenuItem = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这句应该不用改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道之前是不是埋了一个雷,isMenuItem应该放在包裹它的HOC上的,因为这里:
https://github.com/react-component/menu/blob/master/src/util.js#L40
我们都是直接用connectedComponent而不是menuItem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/MenuItemGroup.jsx
Outdated
}, | ||
constructor(props) { | ||
super(props); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor
可以去掉
@@ -188,6 +188,7 @@ exports[`Menu render renders inline menu correctly 1`] = ` | |||
class="rc-menu-submenu-arrow" | |||
/> | |||
</div> | |||
<div /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥会多个 div 出来
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前subpopubmenu会做一个渲染判断:
https://github.com/react-component/menu/blob/master/src/SubPopupMenu.js#L91
现在这部分逻辑(renderChildren)被提到subMenu了(因为Animation被提取到subMenu了)
https://github.com/react-component/menu/pull/133/files#diff-7f8a02620917aa2ed1113e338915793bR374
children的返回结果是要做Trigger的popup:
https://github.com/react-component/menu/pull/133/files#diff-7f8a02620917aa2ed1113e338915793bL449
popup属性不能为null,所以就返回了一个空div,这个不影响用户看到的渲染结果的
src/SubPopupMenu.js
Outdated
level: PropTypes.number, | ||
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']), | ||
triggerSubMenuAction: PropTypes.oneOf(['click', 'hover']), | ||
inlineIndent: PropTypes.number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个原来有当成 string 用的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面在用的时候是这么用的:
style.paddingLeft = props.inlineIndent * props.level;
, 不过它会自动类型转化,为了跟已有的code类型兼容,我改成了:
inlineIndent: PropTypes.oneOfType(PropTypes.number, PropTypes.string),
其他 ok 👍 |
分支要删掉。 |
@picodoth 可以发个大版本,然后更新到 antd feature-3.5.0 分支上,提前合上去发现问题。月底 3.5 上更新掉。 |
@afc163 好的 |