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: Not block input when Input value is undefined #20783

Merged
merged 5 commits into from
Jan 9, 2020
Merged

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 9, 2020

🤔 This is a ...

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

🔗 Related issue link

fix #20776

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Input not block user input when value is undefined.
🇨🇳 Chinese

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

Copy link

@tests-checker tests-checker bot left a comment

Choose a reason for hiding this comment

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

Could you please add tests to make sure this change works as expected?

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 9, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e59301f:

Sandbox Source
antd reproduction template Configuration
antd-input-4 Issue #20776
antd-input-3 Issue #20776

@netlify
Copy link

netlify bot commented Jan 9, 2020

Deploy preview for ant-design ready!

Built with commit e59301f

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

@afc163
Copy link
Member

afc163 commented Jan 9, 2020

Select and Input controlled mode have breaking change in v4 that we should report it in ChangeLog.

};
static getDerivedStateFromProps(nextProps: InputProps, { prevValue }: InputState) {
const newState: Partial<InputState> = { prevValue: nextProps.value };
if (nextProps.value !== undefined || prevValue !== nextProps.value) {
Copy link
Member

Choose a reason for hiding this comment

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

没什么必要比较,整个 constructor 应该都可以删掉。

Copy link
Member Author

Choose a reason for hiding this comment

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

我们的 Table customize 例子里重置是把 filter value 数组从 [e.target.value] 改成 [],它会变成 undefined 成为非受控模式。这会 break 掉原本的行为。所以特地加一个判断,如果是值变化,总是触发一下。

Copy link
Member

Choose a reason for hiding this comment

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

这个 break change 在用户代码里的细节很多,我们会遇到的话用户也会,考虑一下是不是可以不 break。

Copy link
Member Author

Choose a reason for hiding this comment

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

现在唯一的 breaking change 就是 undefined 为非受控,其他的情况切换都是受控。考虑的情况应该是比较全面的了。

Copy link
Member

Choose a reason for hiding this comment

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

👌,至少 undefined 时受控改不受控,不会出现用户无法输入的问题,这个可能引发的问题还是比较小的。

@afc163 afc163 removed the chore label Jan 9, 2020
@codecov
Copy link

codecov bot commented Jan 9, 2020

Codecov Report

Merging #20783 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20783      +/-   ##
==========================================
+ Coverage   97.46%   97.47%   +<.01%     
==========================================
  Files         296      296              
  Lines        6877     6878       +1     
  Branches     1912     1865      -47     
==========================================
+ Hits         6703     6704       +1     
  Misses        174      174
Impacted Files Coverage Δ
components/input/ClearableLabeledInput.tsx 100% <ø> (ø) ⬆️
components/input/Input.tsx 100% <100%> (ø) ⬆️

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 313c8f9...e59301f. Read the comment docs.

@zombieJ zombieJ merged commit 05ebf0f into master Jan 9, 2020
@zombieJ zombieJ deleted the input-control branch January 9, 2020 03:13
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.

[4.0] Different behaviours on Select and other input components
2 participants