Skip to content

fix: preserve min width for numeric popup width#1228

Merged
zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:fix-popup-match-width
Jun 25, 2026
Merged

fix: preserve min width for numeric popup width#1228
zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:fix-popup-match-width

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

背景

popupMatchSelectWidth 传入 number 时,历史行为和文档语义都是下拉框宽度不应小于触发器宽度,即实际宽度应为 max(popupMatchSelectWidth, triggerWidth)

在使用 @rc-component/triggerstretch 逻辑后,number 场景会跳过 stretch,只保留 width: popupMatchSelectWidth,导致当传入值小于选择器宽度时,下拉框会被固定成更窄的宽度。

修改

  • number 场景下将 stretch 设置为 minWidth,让 trigger 继续补充触发器宽度作为最小宽度。
  • 保留现有 width: popupMatchSelectWidth,因此传入值大于触发器宽度时仍按自定义宽度展示。
  • 增加测试覆盖 popupMatchSelectWidth 为 number 且小于触发器宽度的场景。

验证

  • npm test -- tests/Select.test.tsx
  • npm test -- tests/Select.test.tsx -t "dropdownMatchSelectWidth"
  • npm run tsc
  • npm run lint(仅存在既有 warning,无 error)

Summary by CodeRabbit

  • Bug Fixes
    • 修复了下拉触发宽度在传入数字配置时的计算行为,使其与“最小宽度”逻辑保持一致。
    • 优化了下拉菜单在不同宽度配置下的展示效果,避免出现宽度表现不一致的问题。

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e708d3f3-34aa-45ce-a7ec-cdf24313b21d

📥 Commits

Reviewing files that changed from the base of the PR and between 1169cb8 and 71e03e0.

📒 Files selected for processing (2)
  • src/SelectTrigger.tsx
  • tests/Select.test.tsx

Walkthrough

调整了 SelectTriggerpopupMatchSelectWidthstretch 计算规则,并新增测试覆盖数字参数时的下拉宽度与 stretch 值。

Changes

Select 弹层宽度处理

Layer / File(s) Summary
stretch 逻辑调整
src/SelectTrigger.tsx
popupMatchSelectWidthfalse 或数字时,stretch 统一返回 minWidth;其他情况仍返回 width
数字宽度测试
tests/Select.test.tsx
新增用例验证 popupMatchSelectWidth=500 时,下拉样式同时具备 minWidth: 1000pxwidth: 500px,并断言 stretchminWidth

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • zombieJ

Poem

兔耳一抖风儿轻,
下拉宽度更分明。
数字一来不再躲,
minWidth 先把门撑平。
🐇

🚥 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 标题准确概括了本次修改的核心:修复数字型 popupMatchSelectWidth 时对最小宽度的保留。
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/SelectTrigger.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

tests/Select.test.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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.

@QDyanbing QDyanbing marked this pull request as ready for review June 25, 2026 08:48

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

Copy link
Copy Markdown
Contributor

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 stretch calculation in SelectTrigger.tsx to return 'minWidth' instead of null when popupMatchSelectWidth is a number. It also adds a test case in tests/Select.test.tsx to verify that the dropdown menu width is not smaller than the trigger when popupMatchSelectWidth is configured as a number. I have no feedback to provide.

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.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (1169cb8) to head (71e03e0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1228      +/-   ##
==========================================
- Coverage   99.44%   99.44%   -0.01%     
==========================================
  Files          31       31              
  Lines        1265     1263       -2     
  Branches      441      440       -1     
==========================================
- Hits         1258     1256       -2     
  Misses          7        7              

☔ 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.

@zombieJ zombieJ merged commit 63abfd5 into react-component:master Jun 25, 2026
9 of 10 checks passed
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.

2 participants