Skip to content

fix(think): hide retained content when collapsed - #2026

Open
pttydou wants to merge 1 commit into
ant-design:mainfrom
pttydou:fix/think-content-hidden
Open

fix(think): hide retained content when collapsed#2026
pttydou wants to merge 1 commit into
ant-design:mainfrom
pttydou:fix/think-content-hidden

Conversation

@pttydou

@pttydou pttydou commented Aug 23, 2026

Copy link
Copy Markdown

🤔 这个变动的性质是?

  • 🐞 Bug 修复

🔗 相关 Issue

Fixes #2025

💡 需求背景和解决方案

destroyOnHidden={false} 时,Think 折叠后会保留内容节点并添加 ant-think-content-hidden,但缺少对应的隐藏样式,导致内容仍然可见。

为离场后的内容包装节点补充 display: none,并增加回归测试,验证节点仍保留在 DOM 中但不可见。

📝 更新日志

语言 更新描述
🇺🇸 英文 Fix Think content remaining visible after collapse when destroyOnHidden is false.
🇨🇳 中文 修复 Think 在 destroyOnHiddenfalse 时折叠后内容仍然可见的问题。

Summary by CodeRabbit

  • Bug 修复

    • 修复 Think 组件折叠时内容仍可能显示的问题,隐藏状态下内容区域现在会正确设置为不显示。
  • 测试

    • 增强折叠状态测试,确认隐藏内容的显示样式为 none

@dosubot dosubot Bot added the bug Something isn't working label Aug 23, 2026
@coderabbitai

coderabbitai Bot commented Aug 23, 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 64367395-4464-480f-b383-b7b57d691b31

📥 Commits

Reviewing files that changed from the base of the PR and between 25aad7b and 6db80a3.

📒 Files selected for processing (2)
  • packages/x/components/think/__tests__/index.test.tsx
  • packages/x/components/think/style/index.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Think 组件新增 content-hidden 样式,用于在保留内容节点时隐藏折叠内容。测试新增对计算样式 display: none 的断言。

Changes

Think 内容可见性

Layer / File(s) Summary
折叠内容隐藏与测试
packages/x/components/think/style/index.ts, packages/x/components/think/__tests__/index.test.tsx
新增 content-hidden 样式,将折叠内容设置为 display: none。测试验证隐藏内容节点仍存在且其计算样式为 none

Estimated code review effort: 1 (简单) | ~5 分钟

Merge Risk: ⚪ Minimal · up to 6db80

This localized change hides retained Think content after collapse while preserving it in the DOM, with a regression test covering the behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Poem

我是小兔蹦蹦跳,
折叠内容藏得好。
节点仍在不乱跑,
display: none 轻轻罩。
测试确认,安心睡觉。

🚥 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 标题准确概括了折叠时隐藏保留内容的主要修复。
Linked Issues check ✅ Passed 变更为保留在 DOM 中的折叠内容添加 display: none,并通过测试验证,符合问题 #2025 的预期行为。
Out of Scope Changes check ✅ Passed 所有变更均围绕 Think 组件的折叠隐藏逻辑及回归测试展开,未发现无关修改。
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
✨ 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.

@nrps9909 nrps9909 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.

Reviewed exact head 6db80a3 against base 25aad7b.

The leavedClassName is attached to the CSSMotion wrapper after the collapse transition, and the new selector is correctly scoped beneath the Think root. It hides the retained wrapper only after leave without changing removeOnLeave behavior.

Validation performed:

  • Removed the new display rule locally: the submitted retained-content regression failed with computed display block instead of none.
  • Restored exact head: the complete Think suite passes 11/11 tests and 2/2 snapshots.
  • A temporary complementary collapse-to-expand probe verified that the same retained wrapper loses the hidden class and returns to computed display block when reopened, so the rule does not strand content invisibly.
  • packages/x TypeScript noEmit passed.
  • Biome passed both changed files.
  • git diff --check passed.
  • Live PR head rechecked before review and still matches the tested SHA; current remote checks are green.

AI assistance disclosure: Codex was used to inspect the exact motion and style paths, run the red/green and reopen probes, execute static checks, and draft this review. I verified the reported commands and outcomes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Think 组件在 destroyOnHidden={false} 且折叠时,内容仍然可见

2 participants