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

Conversation

Song-aff
Copy link

@Song-aff Song-aff commented Jun 24, 2022

[English Template / 英文模板]

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

antd中 ant-design/ant-design#36074 经过定位,问题在rc-input-number组件中。
可与 https://codesandbox.io/s/lucid-varahamihira-yfwuub?file=/src/App.js 中复现(safari浏览器、中文输入法下)。

其产生原因为 safari 浏览器在中文输入法时,会改变keydown事件触发时间,对format条件进行修改可以解决该问题。

📝 更新日志

语言 更新描述
🇺🇸 英文
🇨🇳 中文

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@vercel
Copy link

vercel bot commented Jun 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
input-number ✅ Ready (Inspect) Visit Preview Jun 24, 2022 at 8:48AM (UTC)

@codecov
Copy link

codecov bot commented Jun 28, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.82%. Comparing base (b9577c8) to head (fa35c26).
Report is 90 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #442   +/-   ##
=======================================
  Coverage   97.82%   97.82%           
=======================================
  Files           9        9           
  Lines         460      460           
  Branches      121      121           
=======================================
  Hits          450      450           
  Misses         10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MadCcc
Copy link
Member

MadCcc commented Jun 28, 2022

来个测试用例?这个直接删了逻辑总感觉有点怪

@Song-aff
Copy link
Author

来个测试用例?这个直接删了逻辑总感觉有点怪

目前项目中的用例都是通过的。
根据代码分析,能够触发判断条件,也就是包含userTypingRef.current = false语句的函数有 onInternalStep ,onKeyDown中(which === KeyCode.ENTER),onKeyUp和onBlur函数。
除了导致问题发生的onKeyUp外,其余函数都可以正常执行 setInputValue 语句。
onInternalStep可以通过改变value满足useUpdateEffect中!newValue.equals(currentParsedValue)条件。
onKeyDown(which === KeyCode.ENTER)和 onBlur 通过 flushInputValue 函数执行。

并没有发现需要依赖!userTypingRef.current触发setInputValue的情况。

@@ -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。后来剥掉的,但是为了兼容就留了这个。

@connie1120
Copy link

此问题项目中遇到了,请问这个修复什么时候合并发布?

@Leonardo-zyh
Copy link

在项目中遇到这个问题,请问该修复何时发布?或者是否有其他兼容方式解决这个问题?😄 @Song-aff

@taptaq
Copy link

taptaq commented Oct 21, 2024

目前在项目中遇到这个问题,想问一下该修复要发布了吗?

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.

8 participants