Skip to content

fix(Sender): apply formatResult to content slots - #1981

Open
jay666mnj wants to merge 2 commits into
ant-design:mainfrom
jay666mnj:fix-sender-content-format-result
Open

fix(Sender): apply formatResult to content slots#1981
jay666mnj wants to merge 2 commits into
ant-design:mainfrom
jay666mnj:fix-sender-content-format-result

Conversation

@jay666mnj

@jay666mnj jay666mnj commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • 🐞 Bug fix
  • ✅ Test Case

🔗 Related Issues

Fixes #1956

💡 Background and Solution

Sender slot mode already supports formatResult, but content slots returned editable DOM text directly when collecting the final value, so formatResult was skipped for content slots.

This change applies formatResult to content slot text when generating getValue().value and the returned slot config value.

📝 Change Log

Language Changelog
🇺🇸 English Sender content slots now respect formatResult when producing the final value.
🇨🇳 Chinese Sender 的 content 类型词槽在生成最终内容时支持 formatResult

Summary by CodeRabbit

  • 新功能
    • content 词槽支持通过 formatResult 处理编辑后的文本,并返回格式化结果。
    • 格式化后的内容会同步反映在发送值和词槽值中。
  • 文档
    • 更新中英文说明,明确 formatResultcontent 词槽中的使用方式。
  • 示例
    • 补充内容词槽格式化结果的示例配置。

@dosubot dosubot Bot added the bug Something isn't working label Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 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

Run ID: 2a853690-bfc7-412f-87a4-024bc62133a8

📥 Commits

Reviewing files that changed from the base of the PR and between 12d8ad7 and 1e4a0d5.

📒 Files selected for processing (4)
  • packages/x/components/sender/__tests__/slot.test.tsx
  • packages/x/components/sender/demo/slot-filling.tsx
  • packages/x/components/sender/index.en-US.md
  • packages/x/components/sender/index.zh-CN.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/x/components/sender/index.en-US.md
  • packages/x/components/sender/index.zh-CN.md
  • packages/x/components/sender/demo/slot-filling.tsx
  • packages/x/components/sender/tests/slot.test.tsx

📝 Walkthrough

Walkthrough

Sender 的 content slot 增加 formatResult 示例与单元测试,验证格式化结果同步反映在返回值和 slot 配置中,并更新中英文文档说明。

Changes

Sender content slot 格式化支持

Layer / File(s) Summary
content slot 格式化验证、示例与文档
packages/x/components/sender/__tests__/slot.test.tsx, packages/x/components/sender/demo/slot-filling.tsx, packages/x/components/sender/index.*.md
新增 formatResult 测试和 location 示例配置,验证格式化值同时出现在 SenderRef.getValue()slotConfig 中,并明确文档中的 content slot 入参语义。

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

Possibly related PRs

  • ant-design/x#1986:同样涉及 Sender 的 content slot formatResult 测试、示例和文档更新。

Suggested labels: documentation, javascript

Suggested reviewers: kimteayon

Poem

兔子捧着尖括号,
胡萝卜旁写格式;
文档说清输入值,
测试验证回填时。
Sender 轻轻一跳,
<Content Value> 闪亮亮。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive 仅从摘要能看到测试、示例和文档更新,无法确认 content slot 的 formatResult 逻辑已在实现层接入。 请补充 use-slot-config-state.ts 的变更或完整 diff,以验证 content slot 的格式化逻辑已确实实现。
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题简洁且准确概括了为 content slot 应用 formatResult 的主要变更。
Out of Scope Changes check ✅ Passed 变更集中在测试、示例和文档,未见与目标无关的额外修改。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@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 introduces support for applying a formatResult function to content slot configurations within the sender component. Specifically, the useSlotConfigState hook has been updated to format the text content when a formatResult function is defined for a content slot, and corresponding unit tests have been added to verify this behavior. There are no review comments, and 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.

@jay666mnj
jay666mnj force-pushed the fix-sender-content-format-result branch from 12d8ad7 to 1e4a0d5 Compare July 22, 2026 13:30
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.

[Good First Issue] Sender 词槽(slot)模式的 content 支持 formatResult

1 participant