Skip to content

Fix placeholder visibility inheritance#1237

Merged
zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:fix-select-hidden-placeholder
Jun 30, 2026
Merged

Fix placeholder visibility inheritance#1237
zombieJ merged 1 commit into
react-component:masterfrom
QDyanbing:fix-select-hidden-placeholder

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

变更内容

  • 移除 placeholder 默认写入的 visibility: visible,让其继承父级 visibility
  • 保留 placeholder 需要隐藏时的 visibility: hidden 行为。
  • 新增父级 visibility: hidden 的回归测试,并更新相关快照。

修复原因

关联 ant-design/ant-design#58567。TreeSelect/Select 外层设置 visibility: hidden 时,placeholder 内联 visibility: visible 会覆盖父级隐藏状态,导致 placeholder 仍可见。

验证

  • npm test 通过(21 suites / 428 tests)
  • npm run lint -- --quiet 通过
  • git diff --check 通过
  • npm run tsc 未通过:本地 node_modules 缺少 package.json 中声明的 devDependency @rc-component/dialog,报错位置是 docs/examples/getPopupContainer.tsx,与本次改动无关。

Summary by CodeRabbit

  • Bug Fixes
    • 优化了占位符的样式处理,避免在某些隐藏场景下强制显示占位内容。
    • 当选择器本身设置为隐藏时,占位符会保持正确的可见性表现,不再覆盖外层样式。
  • Tests
    • 新增相关测试,覆盖选择器隐藏时占位符的显示行为。

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@vercel

vercel Bot commented Jun 30, 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 30, 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: b41dab05-b74b-4efb-9011-e744362c0764

📥 Commits

Reviewing files that changed from the base of the PR and between 6c396cb and b30d2ac.

⛔ Files ignored due to path filters (2)
  • tests/__snapshots__/Combobox.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/ssr.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/SelectInput/Content/Placeholder.tsx
  • tests/placeholder.test.tsx

Walkthrough

Placeholder 组件的内联样式由"始终显式写入 visibility"改为"仅在 showfalse 时才注入 visibility: hidden",showtrue 时不再强制设置该字段。新增一条测试用例,验证父级 visibility: hidden 不被 placeholder 的样式覆盖。

Changes

Placeholder 可见性修复

Layer / File(s) Summary
Placeholder visibility 条件注入及测试
src/SelectInput/Content/Placeholder.tsx, tests/placeholder.test.tsx
Placeholderstyle 仅在 showfalse 时写入 visibility: hiddenshowtrue 时省略该字段;新增测试断言在 Select 设置 style={{ visibility: 'hidden' }} 时,placeholder 的 style 不包含 visibility: visible

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • react-component/select#1167:同样修改了 src/SelectInput/Content/Placeholder.tsx 中的 visibility 处理逻辑,与本 PR 直接相关。
  • react-component/select#1192:调整了 MultipleContentPlaceholder 的渲染时机,影响 placeholder 的可见性行为,与本 PR 的修改方向相关。
  • react-component/select#1194:同样避免显式强制设置 visibility: visible,使父级 visibility: hidden 能正常向下继承。

Suggested reviewers

  • zombieJ

Poem

🐰 小兔子写样式,不再强行 visible
父级藏起来,placeholder 也乖乖跟随,
hidden 时才说话,show 时沉默如风,
测试守护边界,bug 无处遁形~ 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次修复的核心:placeholder 的 visibility 继承问题。
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

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 30, 2026 03:40
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (6c396cb) to head (b30d2ac).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1237   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files          31       31           
  Lines        1271     1271           
  Branches      444      464   +20     
=======================================
  Hits         1264     1264           
  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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. The placeholder no longer forces visibility: visible, preserving parent visibility inheritance while keeping the hidden placeholder path covered.

@zombieJ zombieJ merged commit f70acfe into react-component:master Jun 30, 2026
11 of 12 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