-
Notifications
You must be signed in to change notification settings - Fork 81
feat: add wrapper root #159
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
base: master
Are you sure you want to change the base?
Conversation
""" Walkthrough本次更改主要调整了 Switch 组件的渲染结构和样式:在样式文件中为 Switch 外层新增了 flex 居中规则,并在组件渲染结构中增加了 label 包裹。测试用例也相应更新,事件模拟更精确地定位到 Switch 元素本身。 Changes
Sequence Diagram(s)sequenceDiagram
participant Form
participant SwitchWrapper
participant SwitchButton
Form->>SwitchWrapper: 渲染 label.switch-wrapper
SwitchWrapper->>SwitchButton: 渲染 button.rc-switch
SwitchButton->>SwitchButton: 内部渲染 checked/unchecked children
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes无发现超出关联 issue 目标的更改。 Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
tests/index.spec.jsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 2
🧹 Nitpick comments (4)
assets/index.less (1)
5-8
: 新增.rc-switch-wrapper
建议开放自定义 className / style包装层采用
display: flex
可解决对齐,但目前只能通过固定类名rc-switch-wrapper
选中。
如果业务侧需自定义 margin / theme,仍得写覆盖样式。可以考虑将className
透传到 wrapper,或提供wrapperClassName
prop,增强扩展性。tests/index.spec.js (3)
37-40
: 保持用例一致性:其余wrapper.simulate
也应定位到.rc-switch
此处已改为
wrapper.find('.rc-switch')
,但前面的it('works')
、键盘用例仍直接对根 wrapper 触发事件,结构变动后可能只点击到<label>
。
为避免回归风险,建议统一全部事件触发目标。
45-50
: 同上,保持事件触发一致性同一测试块内多次选择器写法不同,最好提取变量或 helper,减少修改点。
120-122
: mouseup 事件选取方式一致化与 click 用例保持一致有助于阅读与维护。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
assets/index.less
(4 hunks)package.json
(1 hunks)src/index.tsx
(1 hunks)tests/index.spec.js
(2 hunks)
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #159 +/- ##
============================================
- Coverage 100.00% 82.35% -17.65%
============================================
Files 1 1
Lines 34 34
Branches 8 8
============================================
- Hits 34 28 -6
- Misses 0 4 +4
- Partials 0 2 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
添加一层节点,方便使用 flex 布局实现水平对齐
Summary by CodeRabbit
新功能
样式
测试
杂项