-
Notifications
You must be signed in to change notification settings - Fork 269
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(inputNumber): correct onChange, onOverlimit event triggering timing when async & sync #2509
Conversation
Warning Rate limit exceeded@Alex-huxiyang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 16 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Walkthrough此次更改主要增强了 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant InputNumber
participant Component
User->>InputNumber: 输入值
InputNumber->>Component: 触发onChange
Component->>InputNumber: 记录新值
InputNumber->>InputNumber: 检查上下限
InputNumber->>Component: 触发onOverlimit(超出限制)
Component->>InputNumber: 反馈信息
Possibly related issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #2509 +/- ##
==========================================
+ Coverage 83.07% 83.16% +0.08%
==========================================
Files 217 217
Lines 17764 17783 +19
Branches 2554 2564 +10
==========================================
+ Hits 14758 14789 +31
+ Misses 3001 2989 -12
Partials 5 5 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 3
Outside diff range, codebase verification and nitpick comments (2)
src/packages/inputnumber/inputnumber.tsx (1)
Line range hint
201-210
:
代码无误,但请添加测试!
handleInputChange
函数使用clampValue
确保影子值根据夹紧输入值一致更新。根据静态分析工具的提示,以下代码行未覆盖测试:#L208, #L210。请添加相应的测试。
您希望我生成单元测试代码还是创建一个 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 208-208: src/packages/inputnumber/inputnumber.tsx#L208
Added line #L208 was not covered by tests
[warning] 210-210: src/packages/inputnumber/inputnumber.tsx#L210
Added line #L210 was not covered by testssrc/packages/inputnumber/inputnumber.taro.tsx (1)
Line range hint
201-214
:
代码无误,但请添加测试!
handleInputChange
函数使用clampValue
确保影子值根据夹紧输入值一致更新。请添加相应的测试。
您希望我生成单元测试代码还是创建一个 GitHub issue 来跟踪此任务?
onBlur?.(e) | ||
const valueStr = parseValue(e.target.value) | ||
if (valueStr === null) { | ||
if (allowEmpty) { | ||
setShadowValue(null) | ||
} else { | ||
setShadowValue(defaultValue) | ||
} | ||
} else { | ||
setShadowValue(clampValue(valueStr) as any) | ||
} | ||
async && handleValueChange(valueStr, e) |
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.
代码无误,但请添加测试!
handleBlur
函数基于夹紧输入设置影子值,并在异步模式下有条件地调用 handleValueChange
。
根据静态分析工具的提示,以下代码行未覆盖测试:#L226-L230。请添加相应的测试。
您希望我生成单元测试代码还是创建一个 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 226-230: src/packages/inputnumber/inputnumber.tsx#L226-L230
Added lines #L226 - L230 were not covered by tests
不存在
min
、max
时,随着输入而触发,而超出限制时,如max={6},input内容由3 -> 60应该触发onChange
,返回的value为6。而60 -> 600不应该触发onChange
,而这两种情况下都应该触发onOverlimit
。aysnc
状态下,blur时对值进行检验,onChange
和onOverlimit
的触发时机取决于blur时的数据前后的变化。基于以上规则,进行了改造
Summary by CodeRabbit
新功能
InputNumber
组件的事件处理能力,包括新的onChange
和onOverlimit
事件处理程序。错误修复
测试
InputNumber
组件在输入超出最大值时的行为。