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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor Menu related components life cycle methods #15868

Merged
merged 9 commits into from Apr 5, 2019
Merged

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Apr 4, 2019

馃 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Branch merge
  • Other (about what?)

馃懟 What's the background?

ref #15801
(Related issue should close with confriming one by one after this code merge)

close #15800
close #15797
close #15717
close #15776
close #15819
close #15853
close #15849
close #15858

馃挕 Solution

Refactor Menu related components life cycle methods

馃摑 Changelog

Fix Menu shaking & collapse behavior.

鈽戯笍 Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

cc @zy410419243

@zombieJ zombieJ requested review from afc163 and ztplz Apr 4, 2019
@netlify
Copy link

@netlify netlify bot commented Apr 4, 2019

Deploy preview for ant-design ready!

Built with commit 2d668d9

https://deploy-preview-15868--ant-design.netlify.com

@afc163
Copy link
Member

@afc163 afc163 commented Apr 4, 2019

https://deploy-preview-15868--ant-design.netlify.com/components/menu-cn/#components-menu-demo-inline-collapsed 杩欎釜渚嬪瓙琛ㄧ幇鏄敊鐨勩

鍙﹀琛ヤ竴浜涚敤渚嬶紵

@ztplz
Copy link
Contributor

@ztplz ztplz commented Apr 4, 2019

鏈夊繀瑕佺敤context鍚 鐢╬rops浼犱笉濂藉悧
鐪嬩簡涓涓 杩欐牱鏀 灏辨槸寮鸿璺熶互鍓嶉昏緫涓鏍蜂簡

class Sider extends React.Component<SiderProps, SiderState> {
static __ANT_LAYOUT_SIDER: any = true;

class InternalSider extends React.Component<InternalSideProps, SiderState> {
static defaultProps = {
Copy link
Contributor

@orzyyyy orzyyyy Apr 4, 2019

杩 defaultProps 杩樻槸鍒犱簡鍚э紝鐗瑰埆鏄 getDerivedStateFromProps 閲屼細鎺ユ敹 collapsed锛屽緢鎬曞嚭闂鍙堟壘涓嶇潃鍘熷洜

Copy link
Member Author

@zombieJ zombieJ Apr 4, 2019

defaultProps 鍙湁涓 defaultCollapsed锛屼笉鎷呭績鍝垀

title:
zh-CN: 鑷畾涔夎Е鍙戝櫒
en-US: Custom trigger
debug: true
Copy link
Contributor

@orzyyyy orzyyyy Apr 4, 2019

杩欓噷鍒繕浜嗘敼鍥炴潵

Copy link
Member Author

@zombieJ zombieJ Apr 4, 2019

杩欎釜鏄 debug 鏂囦欢锛岀敤鎴蜂笉鐢ㄥ叧娉ㄧ殑銆

export interface SiderState {
collapsed?: boolean;
Copy link
Contributor

@orzyyyy orzyyyy Apr 4, 2019

杩欓噷鐨勬敼鍔ㄨ矊浼兼病鍟ュソ澶勶紝鍙嶈岄渶瑕佸湪鏋勯犲櫒閲屽缁欎釜鍊硷紵

Copy link
Member Author

@zombieJ zombieJ Apr 4, 2019

鍡紝鏄簲璇ラ粯璁ゅ彲閫夈傛敼鎴愬繀椤诲弽鑰屽嚭浜 BUG銆

@@ -257,7 +262,8 @@ class Menu extends React.Component<MenuProps, MenuState> {
}

renderMenu = ({ getPopupContainer, getPrefixCls }: ConfigConsumerProps) => {
const { prefixCls: customizePrefixCls, className, theme } = this.props;
const { prefixCls: customizePrefixCls, className, theme, collapsedWidth } = this.props;
const passProps = omit(this.props, ['collapsedWidth']);
Copy link
Contributor

@orzyyyy orzyyyy Apr 4, 2019

杩欓噷鍙互琛ヤ笂 siderCollapsed锛岀幇鍦ㄦ湁 React does not recognize 鐨 warning

@orzyyyy
Copy link
Contributor

@orzyyyy orzyyyy commented Apr 4, 2019

鏃堕棿涓嶅鐨勮瘽锛岄昏緫杩樻槸鐓т互鍓嶆潵濂姐侻enu 鏈夌偣绁栦紶浠g爜鐨勫懗閬撲簡锛屽姩涓涓嬪氨浼氭锛岀敤渚嬫病瑕嗙洊鍒扮殑鍦版柟涓鏀瑰姩锛屽氨浼氬儚鎴戣繖鏍疯鈥滃墠濂冲弸鈥濈洴濂戒箙...

@@ -68,9 +76,7 @@ const generateId = (() => {
};
})();

class Sider extends React.Component<SiderProps, SiderState> {
static __ANT_LAYOUT_SIDER: any = true;
Copy link
Contributor

@orzyyyy orzyyyy Apr 4, 2019

杩欑帺鎰忔槸鏈璁╂垜璐硅В鐨勶紝涓嶇煡閬撳湪鍝敤鍒帮紝浣嗗垹浜嗗ソ鍍忓氨璺戜笉杩囨祴璇曪紝灏卞緢鎬

Copy link
Member Author

@zombieJ zombieJ Apr 4, 2019

鐪嬭捣鏉ュソ鍍忔槸娌$敤浜嗭紝鎴戝垹浜嗚瘯璇曘

Copy link
Member

@afc163 afc163 Apr 4, 2019

瀵癸紝涓嶉渶瑕佷簡 cad769a

@zombieJ
Copy link
Member Author

@zombieJ zombieJ commented Apr 4, 2019

鏈夊繀瑕佺敤context鍚 鐢╬rops浼犱笉濂藉悧
鐪嬩簡涓涓 杩欐牱鏀 灏辨槸寮鸿璺熶互鍓嶉昏緫涓鏍蜂簡

鐩存帴浼犲氨鍙樻垚 React.cloneElement锛岃繖鏍峰弽鑰屼笉濡 context銆傝屼笖濡傛灉鐢ㄦ埛鑷繁鍖呬簡涓涓 HOC 灏辨寕浜嗐

@codecov
Copy link

@codecov codecov bot commented Apr 4, 2019

Codecov Report

Merging #15868 into master will decrease coverage by 0.01%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15868      +/-   ##
==========================================
- Coverage   95.06%   95.05%   -0.02%     
==========================================
  Files         251      251              
  Lines        6667     6671       +4     
  Branches     1947     1949       +2     
==========================================
+ Hits         6338     6341       +3     
- Misses        328      329       +1     
  Partials        1        1
Impacted Files Coverage 螖
components/menu/SubMenu.tsx 75% <100%> (酶) 猬嗭笍
components/menu/index.tsx 97.29% <100%> (酶) 猬嗭笍
components/layout/layout.tsx 88.57% <63.63%> (-2.06%) 猬囷笍
components/layout/Sider.tsx 90% <85.71%> (+0.46%) 猬嗭笍
components/time-picker/index.tsx 98.59% <0%> (-0.06%) 猬囷笍
components/empty/index.tsx 94.73% <0%> (酶) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 3c75c4f...2d668d9. Read the comment docs.

@zombieJ
Copy link
Member Author

@zombieJ zombieJ commented Apr 4, 2019

Updated. Please check.

orzyyyy
orzyyyy approved these changes Apr 5, 2019
afc163
afc163 approved these changes Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment