-
-
Notifications
You must be signed in to change notification settings - Fork 182
fix: type to mode #725
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: type to mode #725
Conversation
|
@guoyunhe is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
Summary of ChangesHello @guoyunhe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要进行了一项重构,将 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough将 InputNumber 的公共 prop 从 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟 需要关注的点:
Possibly related PRs
Suggested reviewers
诗歌
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2024-10-08T21:56:37.546ZApplied to files:
📚 Learning: 2024-09-29T06:18:11.993ZApplied to files:
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #725 +/- ##
=======================================
Coverage 96.01% 96.01%
=======================================
Files 7 7
Lines 301 301
Branches 81 80 -1
=======================================
Hits 289 289
Misses 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Code Review
本次 PR 将 type 属性重命名为 mode 以避免与原生 HTML 属性冲突,这是一个很好的改进。代码更改整体上是正确的,并且在所有相关文件中都保持了一致性。我只在测试文件中发现了一个小的命名问题,建议进行修改以提高代码清晰度。
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: 0
🧹 Nitpick comments (1)
tests/props.test.tsx (1)
410-415: 测试已正确更新以反映新 API。测试用例正确地使用了
mode="spinner"并验证生成的类名为rc-input-number-mode-spinner。建议可以将测试描述从'type props'更新为'mode props'以保持一致性,但这不是必须的。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/__snapshots__/baseInput.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
assets/index.less(1 hunks)docs/demo/spinner.tsx(3 hunks)src/InputNumber.tsx(8 hunks)tests/props.test.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: bombillazo
Repo: react-component/input-number PR: 644
File: src/InputNumber.tsx:173-174
Timestamp: 2024-09-29T06:18:11.993Z
Learning: In `src/InputNumber.tsx`, within the `InternalInputNumber` component, the state variables `prevValueRef` and `inputValueRef` are typed as `string | number` to maintain consistency with existing code.
📚 Learning: 2024-09-29T06:18:11.993Z
Learnt from: bombillazo
Repo: react-component/input-number PR: 644
File: src/InputNumber.tsx:173-174
Timestamp: 2024-09-29T06:18:11.993Z
Learning: In `src/InputNumber.tsx`, within the `InternalInputNumber` component, the state variables `prevValueRef` and `inputValueRef` are typed as `string | number` to maintain consistency with existing code.
Applied to files:
tests/props.test.tsxsrc/InputNumber.tsxdocs/demo/spinner.tsx
📚 Learning: 2024-10-08T21:56:37.546Z
Learnt from: bombillazo
Repo: react-component/input-number PR: 644
File: tests/validator.test.tsx:34-83
Timestamp: 2024-10-08T21:56:37.546Z
Learning: In `tests/validator.test.tsx`, the test cases focus on the `validator` function. When the validator condition is not met, the input value should not change. The `formatter` is tested separately in another file.
Applied to files:
tests/props.test.tsx
📚 Learning: 2024-10-08T21:56:37.546Z
Learnt from: bombillazo
Repo: react-component/input-number PR: 644
File: src/InputNumber.tsx:393-395
Timestamp: 2024-10-08T21:56:37.546Z
Learning: The `InputNumber` component does not use error states or messages; it is designed to prevent the value from updating if validation fails without displaying additional feedback to the user.
Applied to files:
src/InputNumber.tsxdocs/demo/spinner.tsx
🧬 Code graph analysis (1)
src/InputNumber.tsx (1)
src/StepHandler.tsx (1)
StepHandler(26-114)
🔇 Additional comments (6)
docs/demo/spinner.tsx (1)
23-23: LGTM!演示代码已正确更新。三处使用场景(受控、非受控、changeOnBlur)都已正确地从
type="spinner"更新为mode="spinner",与新的 API 保持一致。Also applies to: 57-57, 68-68
assets/index.less (1)
137-155: LGTM!CSS 类名已正确更新。所有样式选择器都已从
-type-spinner一致地更新为-mode-spinner,与组件生成的新类名匹配。样式结构和行为保持不变。src/InputNumber.tsx (4)
67-67: LGTM!公共 API 接口已更新。将
type重命名为mode避免了与原生 HTML<input>元素的type属性冲突,这是一个合理的改进。类型定义保持清晰,支持'input'和'spinner'两种模式。
637-667: LGTM!条件渲染逻辑正确实现了两种模式。代码正确地根据
mode值实现了不同的布局:
mode === 'input':将上下按钮包裹在一个容器中(传统的垂直布局)mode === 'spinner':将下按钮和上按钮分别放置在输入框两侧(内联水平布局)渲染逻辑清晰且正确。
675-675: LGTM!默认值和 CSS 类名生成已正确实现。
- 第 675 行:设置默认值为
'input',为未指定该属性的用户提供向后兼容性- 第 710 行:CSS 类名生成更新为
${prefixCls}-mode-${mode},与样式文件中的更新保持一致Also applies to: 710-710
67-67: 验证完成:所有type属性用法已更新,迁移充分彻底。搜索结果确认代码库中不存在任何
InputNumber组件仍在使用旧的type属性。所有type=匹配项均为标准 HTML 元素(<button>、<input>),与此次破坏性变更无关。验证范围:
- ✅ 演示文件(
docs/demo/spinner.tsx、simple.tsx、decimal.tsx等):所有 InputNumber 组件已使用新属性,无旧代码- ✅ 测试文件:所有测试中 InputNumber 用法已更新
- ✅ 源代码:无遗留的
type属性引用本次 PR 的属性迁移完全且全面,用户代码需要从
type="spinner"|"input"更新至mode="spinner"|"input"。
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
避免和原生 type 冲突
Summary by CodeRabbit
发布说明
破坏性变更
type已更名为mode,取值仍为 'input' 或 'spinner',请更新使用处。-type-spinner改为-mode-spinner,影响基于类名的自定义样式。测试
mode属性。