Skip to content
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

Merged
merged 8 commits into from
Apr 23, 2018
Merged

chore: refactor/remove mixin #133

merged 8 commits into from
Apr 23, 2018

Conversation

picodoth
Copy link
Contributor

@picodoth picodoth commented Apr 18, 2018

  • Handle menu.onKeyDown usage in rc-select

@picodoth picodoth requested a review from yesmeck April 18, 2018 13:45
@coveralls
Copy link

coveralls commented Apr 18, 2018

Coverage Status

Coverage increased (+1.8%) to 99.666% when pulling d8e200b on rm-mixin into 6eb19f0 on master.

@yesmeck
Copy link
Member

yesmeck commented Apr 18, 2018

Remove all createReactClass, use ES class.

return true;
});
if (!this.props.defaultActiveFirst && activeIndex !== -1) {
if (allDisabled(children.slice(activeIndex, len - 1))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个 if 可以合并。

}
const start = (activeIndex + 1) % len;
let i = start;
for (; ;) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 while 是不是清晰一点。

if (i === start) {
return null;
}
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 else 是多余的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是多余的,如果找到一个有效的child就立马返回啊

if (c) {
this.instanceArray[index] = c;
}
}

const SubPopupMenu = createReactClass({
Copy link
Member

@afc163 afc163 Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉了 Mixin 就可以用 ES6 class 了。

getStore() {
const store = this.props.store;

return store;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return this.props.store?

@picodoth picodoth changed the title [WIP]chore: refactor/remove mixin chore: refactor/remove mixin Apr 19, 2018
@picodoth
Copy link
Contributor Author

@yesmeck @afc163 take another look

},
});

MenuItem.isMenuItem = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句应该不用改

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
constructor(props) {
super(props);
}
Copy link
Member

@yesmeck yesmeck Apr 19, 2018

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 />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥会多个 div 出来

Copy link
Contributor Author

@picodoth picodoth Apr 20, 2018

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,这个不影响用户看到的渲染结果的

level: PropTypes.number,
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']),
triggerSubMenuAction: PropTypes.oneOf(['click', 'hover']),
inlineIndent: PropTypes.number,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个原来有当成 string 用的。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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),

@yesmeck
Copy link
Member

yesmeck commented Apr 23, 2018

其他 ok 👍

@picodoth picodoth merged commit e688ac2 into master Apr 23, 2018
@yesmeck
Copy link
Member

yesmeck commented Apr 23, 2018

分支要删掉。

@afc163 afc163 deleted the rm-mixin branch April 23, 2018 16:16
@picodoth
Copy link
Contributor Author

@afc163
Copy link
Member

afc163 commented Apr 27, 2018

@picodoth 可以发个大版本,然后更新到 antd feature-3.5.0 分支上,提前合上去发现问题。月底 3.5 上更新掉。

@picodoth
Copy link
Contributor Author

@afc163 好的

@picodoth
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants