Skip to content

fix: do not forward disabled to trigger#261

Merged
zombieJ merged 1 commit into
masterfrom
codex/filter-disabled-prop
Jul 10, 2026
Merged

fix: do not forward disabled to trigger#261
zombieJ merged 1 commit into
masterfrom
codex/filter-disabled-prop

Conversation

@zombieJ

@zombieJ zombieJ commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

  • filter the undeclared disabled prop before forwarding remaining props to Trigger
  • preserve rc-dropdown controlled visibility behavior across Trigger upgrades
  • add a regression test for the Trigger prop boundary

Validation

  • ut compile
  • ut test -- --runInBand
  • ut tsc
  • ut lint

Summary by CodeRabbit

  • Bug Fixes
    • 修复下拉菜单禁用状态下,相关属性可能被错误传递到底层触发器组件的问题。
    • 确保禁用时弹层显示逻辑仍按预期工作,避免异常交互。
  • Tests
    • 新增测试用例:验证禁用时触发器不会接收到禁用属性,并会正确获得弹层显示所需状态。

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@zombieJ, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efa5bcd3-034a-4024-90de-3384bd896733

📥 Commits

Reviewing files that changed from the base of the PR and between df2f31a and 2d76ff4.

📒 Files selected for processing (2)
  • src/Dropdown.tsx
  • tests/props.test.tsx

Walkthrough

Dropdown 不再将 disabled 透传给内部 Trigger,并新增测试验证该属性被排除且 popupVisible 仍会传递。

Changes

Dropdown 属性透传

Layer / File(s) Summary
过滤 Trigger 属性并补充测试
src/Dropdown.tsx, tests/props.test.tsx
通过解构从传递给 Trigger 的属性中移除 disabled,并测试 disabled: true 时不转发该属性且保留 popupVisible: true

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

小兔挥爪改属性,
disabled 藏起来;
popupVisible 仍闪亮,
Trigger 安静收好包。
测试萝卜甜又脆!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次改动的核心:不再将 disabled 透传给 Trigger。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/filter-disabled-prop

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/Dropdown.tsx Outdated
Comment on lines 27 to 30
children: React.ReactElement;
minOverlayWidthMatchTrigger?: boolean;
arrow?: boolean;
onVisibleChange?: (visible: boolean) => void;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
children: React.ReactElement;
minOverlayWidthMatchTrigger?: boolean;
arrow?: boolean;
onVisibleChange?: (visible: boolean) => void;
children: React.ReactElement;
minOverlayWidthMatchTrigger?: boolean;
arrow?: boolean;
onVisibleChange?: (visible: boolean) => void;
disabled?: boolean;

Comment thread src/Dropdown.tsx Outdated
Comment on lines +157 to +159
{...omit(otherProps as typeof otherProps & { disabled?: boolean }, [
'disabled',
])}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With disabled declared in DropdownProps, we can remove the verbose type cast as typeof otherProps & { disabled?: boolean } and simply call omit(otherProps, ['disabled']) directly.

Suggested change
{...omit(otherProps as typeof otherProps & { disabled?: boolean }, [
'disabled',
])}
{...omit(otherProps, [
'disabled',
])}

@zombieJ zombieJ force-pushed the codex/filter-disabled-prop branch from 6a516c1 to 44e36da Compare July 10, 2026 13:42
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 2d76ff4.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.21%. Comparing base (d76e391) to head (2d76ff4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed ❌ Failed
🔗 Preview https://react-component-dropdown-preview-pr-261.surge.sh (may be unavailable)
📝 Commit2d76ff4
🪵 LogsView logs
📋 Build log (last lines)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error node_modules/eslint-plugin-react
npm error   dev eslint-plugin-react@"^7.37.5" from the root project
npm error   eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error   node_modules/@umijs/fabric
npm error     @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error     node_modules/rc-test
npm error       dev rc-test@"^7.1.3" from the root project
npm error
npm error Conflicting peer dependency: eslint@9.39.4
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error   node_modules/eslint-plugin-react
npm error     dev eslint-plugin-react@"^7.37.5" from the root project
npm error     eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error     node_modules/@umijs/fabric
npm error       @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error       node_modules/rc-test
npm error         dev rc-test@"^7.1.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/runner/.npm/_logs/2026-07-10T13_58_46_468Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-07-10T13_58_46_468Z-debug-0.log

🤖 Powered by surge-preview

@zombieJ zombieJ marked this pull request as ready for review July 10, 2026 13:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between d76e391 and 44e36da.

📒 Files selected for processing (2)
  • src/Dropdown.tsx
  • tests/props.test.tsx

@zombieJ zombieJ force-pushed the codex/filter-disabled-prop branch from 44e36da to df2f31a Compare July 10, 2026 13:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 44e36da and df2f31a.

📒 Files selected for processing (2)
  • src/Dropdown.tsx
  • tests/props.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/props.test.tsx

@zombieJ zombieJ force-pushed the codex/filter-disabled-prop branch from df2f31a to 2d76ff4 Compare July 10, 2026 13:52
@zombieJ zombieJ merged commit a87de85 into master Jul 10, 2026
13 checks passed
@zombieJ zombieJ deleted the codex/filter-disabled-prop branch July 10, 2026 14:00
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.

1 participant