Skip to content

fix: ConversationsItem title display [Object Object] and support extr… #898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2025

Conversation

yuanliu147
Copy link
Contributor

@yuanliu147 yuanliu147 commented Jun 5, 2025

…a html properties

中文版模板 / Chinese template

🤔 This is a ...

修复 #897 ,且让其支持其它 html 属性

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

Summary by CodeRabbit

  • 新功能

    • 支持为每个会话项单独自定义样式和类名,提升会话列表的灵活性和个性化展示。
  • 优化

    • 改进会话项的标题属性,当标签为对象时将不再显示悬浮提示,提升用户体验。

Copy link
Contributor

github-actions bot commented Jun 5, 2025

Preview is ready

Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

📝 Walkthrough

Walkthrough

本次更改主要扩展了会话项(ConversationItem)组件的灵活性。现在每个会话对象可自定义 className 和 style,并支持所有 <li> 元素的原生 HTML 属性(除 onClick 外)。此外,title 属性的设置也进行了条件优化。

Changes

文件/分组 变更摘要
components/conversations/Item.tsx 优化了 <li> 的 title 属性逻辑:仅当 label 不是对象时才设置 title。
components/conversations/index.tsx 支持将 convInfo 的所有属性传递给 ConversationsItem,合并 className 和 style,实现更细粒度的自定义。
components/conversations/interface.ts Conversation 接口继承了 <li> 的所有 HTML 属性(排除 onClick),提升了类型灵活性。

Sequence Diagram(s)

sequenceDiagram
    participant Parent as Conversations
    participant Item as ConversationsItem
    Note right of Parent: 遍历 convInfo 列表
    Parent->>Item: 传递 convInfo 的所有属性(含 className/style)
    Item->>Item: 根据 label 类型决定是否设置 title
    Item->>UI: 渲染 <li>,应用合并后的 className 和 style
Loading

Possibly related PRs

Suggested reviewers

  • afc163

Poem

兔子敲键盘,代码轻轻弹,
会话项变灵活,属性任你添。
title 智能判断,className 随心换,
样式随风舞,前端更灿烂!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ff1fa5 and c6d2c22.

⛔ Files ignored due to path filters (1)
  • components/conversations/__tests__/__snapshots__/index.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • components/conversations/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/conversations/index.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot bot added the bug Something isn't working label Jun 5, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
components/conversations/interface.ts (1)

49-52: 修复文档与类型定义的不一致性

注释中提到排除了 onClickdirection,但类型定义中只排除了 onClick。建议要么更新类型定义排除 direction,要么修正注释内容以保持一致性。

  /**
-  * @desc html 原生属性(除 onClick, direction 以外)
-  * @descEN html native attributes(except onClick, direction)
+  * @desc html 原生属性(除 onClick 以外)
+  * @descEN html native attributes(except onClick)
   */
components/conversations/index.zh-CN.md (1)

58-58: 修正文档描述以保持一致性

文档描述提到排除 onClickdirection,但实际类型定义中只排除了 onClick。建议修正描述以匹配实际的类型定义。

-| htmlAttrs | html 原生属性(除 onClick, direction 以外) | Omit<React.HTMLAttributes<HTMLLIElement>, 'onClick'> | - | - |
+| htmlAttrs | html 原生属性(除 onClick 以外) | Omit<React.HTMLAttributes<HTMLLIElement>, 'onClick'> | - | - |
components/conversations/index.en-US.md (1)

57-57: 优化文案和版本标注
建议将 html native attributes(except onClick, direction) 修改为 HTML 原生属性(不包括 onClick 和 direction),并在 Version 列中补充新增该属性的版本号以便追溯。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aae1337 and 551b512.

📒 Files selected for processing (5)
  • components/conversations/Item.tsx (1 hunks)
  • components/conversations/index.en-US.md (1 hunks)
  • components/conversations/index.tsx (1 hunks)
  • components/conversations/index.zh-CN.md (1 hunks)
  • components/conversations/interface.ts (1 hunks)
🔇 Additional comments (3)
components/conversations/Item.tsx (1)

78-78: 很好的修复!

条件设置 title 属性的逻辑正确解决了当 info.label 是 React 元素或对象时显示 "[Object Object]" 的问题。这是对原始问题的直接且有效的修复。

components/conversations/index.tsx (2)

162-162: 良好的属性传递实现

正确地将 htmlAttrs 展开到 ConversationsItem 组件,使得每个对话项都能接受自定义的 HTML 属性。


167-172: 完善的属性合并逻辑

classNamestyle 的合并逻辑实现得很好,既保留了现有的样式配置,又允许通过 htmlAttrs 进行单项自定义。属性优先级顺序合理。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 6, 2025
Copy link
Member

@afc163 afc163 left a comment

Choose a reason for hiding this comment

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

理论上其他属性都可以透传就好,不需要加新属性。

@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label Jun 6, 2025
Copy link

codecov bot commented Jun 6, 2025

Bundle Report

Changes will decrease total bundle size by 540.33kB (-79.57%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antdx-array-push 138.74kB -540.33kB (-79.57%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js -540.33kB 138.74kB -79.57%

Copy link
Member

@afc163 afc163 left a comment

Choose a reason for hiding this comment

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

理论上其他属性都可以透传就好,不需要加新属性。

@yuanliu147 yuanliu147 requested a review from afc163 June 7, 2025 09:08
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 9, 2025
@afc163
Copy link
Member

afc163 commented Jun 9, 2025

看下测试用例。

@yuanliu147
Copy link
Contributor Author

yuanliu147 commented Jun 9, 2025

看下测试用例。

原因是 属性展开后 label,disabled,icon 三个传递到了 li 元素。(同时命中 Conversation 以及 pickAttrs)

@yuanliu147 yuanliu147 requested a review from afc163 June 9, 2025 07:38
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.53%. Comparing base (aae1337) to head (c6d2c22).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #898   +/-   ##
=======================================
  Coverage   92.52%   92.53%           
=======================================
  Files          69       69           
  Lines        1552     1554    +2     
  Branches      400      418   +18     
=======================================
+ Hits         1436     1438    +2     
  Misses        116      116           

☔ View full report in Codecov by Sentry.
📢 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.

@afc163 afc163 merged commit 28f8f61 into ant-design:main Jun 9, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants