-
-
Notifications
You must be signed in to change notification settings - Fork 49.2k
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
Conversation
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.
Could you please add tests to make sure this change works as expected?
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:
|
Deploy preview for ant-design ready! Built with commit e59301f |
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) { |
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 应该都可以删掉。
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.
我们的 Table customize 例子里重置是把 filter value 数组从 [e.target.value] 改成 [],它会变成 undefined
成为非受控模式。这会 break 掉原本的行为。所以特地加一个判断,如果是值变化,总是触发一下。
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.
这个 break change 在用户代码里的细节很多,我们会遇到的话用户也会,考虑一下是不是可以不 break。
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.
现在唯一的 breaking change 就是 undefined 为非受控,其他的情况切换都是受控。考虑的情况应该是比较全面的了。
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.
👌,至少 undefined 时受控改不受控,不会出现用户无法输入的问题,这个可能引发的问题还是比较小的。
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
🤔 This is a ...
🔗 Related issue link
fix #20776
💡 Background and solution
📝 Changelog
undefined
.☑️ Self Check before Merge