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: Modify format conditions #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ const InputNumber = React.forwardRef(

// When user typing from `1.2` to `1.`, we should not convert to `1` immediately.
// But let it go if user set `formatter`
if (!newValue.equals(currentParsedValue) || !userTypingRef.current || formatter) {
if (!newValue.equals(currentParsedValue) || formatter) {
Copy link
Member

Choose a reason for hiding this comment

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

看看能不能找到当初加 !userTypingRef.current 的用意

Copy link
Author

Choose a reason for hiding this comment

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

#293
@zombieJ 于该次变动中引入,变动量有点大,可能需要本人判断下。

Copy link

Choose a reason for hiding this comment

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

请问加入userTypingRef.current的用意是什么

Copy link
Member

Choose a reason for hiding this comment

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

兼容古早的 string number 转换的,过去 onChange 事件如果不是有效值就会给 string value,是有效值就会给 number value。后来剥掉的,但是为了兼容就留了这个。

// Update value as effect
setInputValue(newValue, userTypingRef.current);
}
Expand Down