fix: do not forward disabled to trigger#261
Conversation
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughDropdown 不再将 ChangesDropdown 属性透传
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request updates the @rc-component/trigger and @rc-component/util dependencies, simplifies import paths across several files, and prevents the disabled prop from being forwarded to the underlying Trigger component. It also adds a test suite to verify this behavior. The review feedback suggests improving type safety and code readability by explicitly adding the disabled prop to DropdownProps, which would eliminate the need for a verbose type cast when omitting the prop.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| children: React.ReactElement; | ||
| minOverlayWidthMatchTrigger?: boolean; | ||
| arrow?: boolean; | ||
| onVisibleChange?: (visible: boolean) => void; |
There was a problem hiding this comment.
Since disabled is being filtered out from the props forwarded to Trigger, it should be explicitly declared in DropdownProps. This not only makes it type-safe for consumers who might pass disabled to <Dropdown />, but also allows us to avoid the type cast when calling omit later.
| children: React.ReactElement; | |
| minOverlayWidthMatchTrigger?: boolean; | |
| arrow?: boolean; | |
| onVisibleChange?: (visible: boolean) => void; | |
| children: React.ReactElement; | |
| minOverlayWidthMatchTrigger?: boolean; | |
| arrow?: boolean; | |
| onVisibleChange?: (visible: boolean) => void; | |
| disabled?: boolean; |
| {...omit(otherProps as typeof otherProps & { disabled?: boolean }, [ | ||
| 'disabled', | ||
| ])} |
There was a problem hiding this comment.
With disabled declared in DropdownProps, we can remove the verbose type cast as typeof otherProps & { disabled?: boolean } and simply call omit(otherProps, ['disabled']) directly.
| {...omit(otherProps as typeof otherProps & { disabled?: boolean }, [ | |
| 'disabled', | |
| ])} | |
| {...omit(otherProps, [ | |
| 'disabled', | |
| ])} |
6a516c1 to
44e36da
Compare
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #261 +/- ##
=======================================
Coverage 98.21% 98.21%
=======================================
Files 5 5
Lines 112 112
Branches 34 34
=======================================
Hits 110 110
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
❌ Deploy failed
📋 Build log (last lines)🤖 Powered by surge-preview |
|||||||||
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/props.test.tsx (1)
5-19: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value建议在测试间清理 mock 状态。
mockTriggerRender是模块级变量,当前仅有一个测试不会出问题。但如果后续新增测试,mock.calls[0]会引用到第一个测试的调用记录而非当前测试。建议添加afterEach清理 mock。♻️ 建议的改进
const mockTriggerRender = jest.fn(); + +afterEach(() => { + mockTriggerRender.mockClear(); +});🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/props.test.tsx` around lines 5 - 19, 在 tests/props.test.tsx 中为模块级 mockTriggerRender 添加 afterEach 清理逻辑,在每个测试结束后调用 mockClear 或 clearAllMocks,确保后续测试只读取当前测试产生的调用记录。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/props.test.tsx`:
- Around line 5-19: 在 tests/props.test.tsx 中为模块级 mockTriggerRender 添加 afterEach
清理逻辑,在每个测试结束后调用 mockClear 或 clearAllMocks,确保后续测试只读取当前测试产生的调用记录。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 70876ac5-636a-4512-a108-df0048f673ed
📒 Files selected for processing (2)
src/Dropdown.tsxtests/props.test.tsx
44e36da to
df2f31a
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Dropdown.tsx (1)
68-70: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value考虑将
disabled直接添加到DropdownProps接口中。当前使用
props as DropdownProps & { disabled?: boolean }类型断言来解构disabled,这虽然有效,但属于类型层面的变通方案。更清晰的做法是在DropdownProps接口定义中直接声明disabled?: boolean,这样可以避免类型断言并提升类型安全性。如果
disabled不希望作为公开 API 暴露,当前方式也是可以接受的。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Dropdown.tsx` around lines 68 - 70, 将 disabled?: boolean 直接添加到 DropdownProps 接口,并在对应的 props 解构中移除 “as DropdownProps & { disabled?: boolean }” 类型断言;确保 Dropdown 组件仍按现有逻辑处理 disabled,同时通过接口明确其类型。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/Dropdown.tsx`:
- Around line 68-70: 将 disabled?: boolean 直接添加到 DropdownProps 接口,并在对应的 props
解构中移除 “as DropdownProps & { disabled?: boolean }” 类型断言;确保 Dropdown 组件仍按现有逻辑处理
disabled,同时通过接口明确其类型。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3249240d-0db9-4524-89ed-71360978788f
📒 Files selected for processing (2)
src/Dropdown.tsxtests/props.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/props.test.tsx
df2f31a to
2d76ff4
Compare

Summary
disabledprop before forwarding remaining props to TriggerValidation
ut compileut test -- --runInBandut tscut lintSummary by CodeRabbit