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

fix: Calendar select can't switch #15338

Merged
merged 11 commits into from Mar 12, 2019

Conversation

Projects
None yet
4 participants
@zy410419243
Copy link
Contributor

commented Mar 12, 2019

First of all, thank you for your contribution! 😄

New feature please send pull request to feature branch, and rest to master branch.
Pull request will be merged after one of collaborators approve.
Please makes sure that these form are filled before submitting your pull request, thank you!

[中文版模板 / Chinese template]

🤔 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?

  1. Describe the source of requirement, like related issue link.

    To close #15334

  2. Describe the problem and the scenario.

💡 Solution

  1. How to fix the problem, and list final API implementation and usage sample if that is an new feature.

  2. GIF or snapshot should be provided if includes UI/interactive modification.

📝 Changelog description

Describe changes from user side, and list all potential break changes or other risks.

Fix Calendar can't switch.

修复 Calendar 无法切换类型的问题。

☑️ 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

zy410419243 added some commits Mar 12, 2019

@netlify

This comment has been minimized.

Copy link

commented Mar 12, 2019

Deploy preview for ant-design ready!

Built with commit d53e003

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

@afc163

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

We should add some test cases..

@netlify

This comment has been minimized.

Copy link

commented Mar 12, 2019

Deploy preview for ant-design ready!

Built with commit 5c1c4e7

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

@codecov

This comment has been minimized.

Copy link

commented Mar 12, 2019

Codecov Report

Merging #15338 into master will increase coverage by 0.07%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15338      +/-   ##
==========================================
+ Coverage   94.11%   94.18%   +0.07%     
==========================================
  Files         250      250              
  Lines        6643     6642       -1     
  Branches     1907     1906       -1     
==========================================
+ Hits         6252     6256       +4     
+ Misses        390      385       -5     
  Partials        1        1
Impacted Files Coverage Δ
components/calendar/Header.tsx 82.27% <100%> (ø) ⬆️
components/calendar/index.tsx 91.2% <20%> (+2.07%) ⬆️
components/_util/wave.tsx 87.5% <0%> (+2.88%) ⬆️

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 43b13f6...222c744. Read the comment docs.

@codecov

This comment has been minimized.

Copy link

commented Mar 12, 2019

Codecov Report

Merging #15338 into master will increase coverage by 0.16%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15338      +/-   ##
==========================================
+ Coverage   94.11%   94.27%   +0.16%     
==========================================
  Files         250      250              
  Lines        6643     6640       -3     
  Branches     1907     1938      +31     
==========================================
+ Hits         6252     6260       +8     
+ Misses        390      379      -11     
  Partials        1        1
Impacted Files Coverage Δ
components/calendar/Header.tsx 87.34% <100%> (+5.06%) ⬆️
components/calendar/index.tsx 96.62% <100%> (+7.49%) ⬆️

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 43b13f6...5c1c4e7. Read the comment docs.

@afc163

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

所以,问题是出在哪里了?

@zy410419243

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2019

getDerivedStateFromProps 里判断 props 里有 mode 就更新 state, 然后 defaultProps.mode 始终都是 month,也就是 Header 的 onChange 始终没法改变外部的 mode

实际上去掉这个 defaultProps 就完了,其它改动是因为 type 老是变来变去,实在头疼就改了

测试用例在补,不要慌

@afc163

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

话说这个组件用的人真少,居然都没人报 bug。

@zy410419243

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2019

何不弄个问卷,或者直接在文档网页上弄个点击统计

不但方便路人看热闹,自己还能看到哪些组件该重点维护

这组件出问题我还是在写测试用例的时候发现的

@afc163

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

image

@zombieJ

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

话说这个组件用的人真少,居然都没人报 bug。

3.1.4.x 是好的:https://codesandbox.io/s/m9ol1o05nj

感觉迁移 lifecycle j经常遇到这类问题,合之前需要多点点 😄

ref: 4601144

@ztplz

ztplz approved these changes Mar 12, 2019

@zombieJ

This comment has been minimized.

Copy link
Member

commented Mar 12, 2019

- const mode = type === 'date' ? 'month' : 'year';
- if (this.state.mode !== mode) {
-     this.setState({ mode });	
-     this.onPanelChange(this.state.value, mode);	
- }

+ setType = (mode: CalendarMode) => {
+   this.setState({ mode });
+   this.onPanelChange(this.state.value, mode);
+ }

感觉 type 也没什么用了,全部统一掉吧:

  • mode => type
  • setType => setMode
  • onHeaderTypeChange => onHeaderModeChange

@afc163 afc163 merged commit 3ad1eea into ant-design:master Mar 12, 2019

25 of 27 checks passed

Header rules No header rules processed
Details
Pages changed 12 new files uploaded
Details
Codacy/PR Quality Review Up to standards. A positive pull request.
Details
CodeFactor No issues found.
Details
LGTM analysis: JavaScript No new or fixed alerts
Details
Mixed content No mixed content detected
Details
Redirect rules 18 redirect rules processed
Details
ant-design.ant-design #ant design succeeded
Details
ci/circleci: compile Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_dist Your tests passed on CircleCI!
Details
ci/circleci: test_dist_15 Your tests passed on CircleCI!
Details
ci/circleci: test_dom Your tests passed on CircleCI!
Details
ci/circleci: test_dom_15 Your tests passed on CircleCI!
Details
ci/circleci: test_es Your tests passed on CircleCI!
Details
ci/circleci: test_es_15 Your tests passed on CircleCI!
Details
ci/circleci: test_lib Your tests passed on CircleCI!
Details
ci/circleci: test_lib_15 Your tests passed on CircleCI!
Details
ci/circleci: test_node Your tests passed on CircleCI!
Details
ci/circleci: test_node_15 Your tests passed on CircleCI!
Details
codebeat no reportable quality changes
Details
codecov/patch 100% of diff hit (target 94.11%)
Details
codecov/project 94.27% (+0.16%) compared to 43b13f6
Details
deploy/netlify Deploy preview ready!
Details
security/snyk - package.json (paranoidjk) No manifest changes detected

@zy410419243 zy410419243 deleted the zy410419243:calendar branch Mar 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.