Skip to content

feat(Ellipsis): add onEllipsis callback to Ellipsis component #6893

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Meet-student
Copy link

@Meet-student Meet-student commented Jun 24, 2025

Summary by CodeRabbit

  • 新功能
    • Ellipsis 组件新增 onEllipsis 回调属性,支持在内容展开或收起时触发回调,并返回当前状态和事件对象。
    • 在示例中新增 onEllipsis 回调,触发时显示对应的展开或收起提示。
  • 文档
    • 更新中英文文档,增加 onEllipsis 属性说明及用法示例。
  • 测试
    • 新增 onEllipsis 回调相关的单元测试,验证其在展开和收起时能正确触发。

Copy link
Contributor

github-actions bot commented Jun 24, 2025

Prepare preview

Copy link

coderabbitai bot commented Jun 24, 2025

📝 Walkthrough

"""

Walkthrough

本次变更为 Ellipsis 组件新增了一个 onEllipsis 回调属性,用于在文本展开或收起时触发。相关文档已同步更新,并增加了对应的测试用例和演示代码。

Changes

文件/分组 变更摘要
src/components/ellipsis/ellipsis.tsx 为 EllipsisProps 新增可选回调属性 onEllipsis,用于监听展开/收起事件
src/components/ellipsis/index.en.md
src/components/ellipsis/index.zh.md
文档中新增 onEllipsis 属性说明,描述其参数和作用
src/components/ellipsis/demos/demo1.tsx 演示示例中添加 onEllipsis 回调,展示展开/收起时的提示
src/components/ellipsis/tests/ellipsis.test.tsx 新增测试用例,验证 onEllipsis 回调在展开/收起时能正确触发

Sequence Diagram(s)

sequenceDiagram
    participant User as 用户
    participant Ellipsis as Ellipsis组件
    participant App as 应用/回调

    User->>Ellipsis: 点击展开/收起链接
    Ellipsis->>App: 触发 onEllipsis(ellipsis, event)
    App-->>User: 响应(如提示、处理等)
Loading

Poem

🐰
省略号闪烁展与收,
回调新添乐悠悠。
测试验证真灵巧,
文档同步记心头。
代码如诗轻轻走,
变化藏在细节中。

"""


📜 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 13219d1 and 388a13a.

📒 Files selected for processing (4)
  • src/components/ellipsis/demos/demo1.tsx (2 hunks)
  • src/components/ellipsis/ellipsis.tsx (3 hunks)
  • src/components/ellipsis/index.en.md (1 hunks)
  • src/components/ellipsis/index.zh.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/ellipsis/demos/demo1.tsx
  • src/components/ellipsis/index.en.md
  • src/components/ellipsis/index.zh.md
  • src/components/ellipsis/ellipsis.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment

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 auto-generate unit tests to generate unit tests for 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.

@Meet-student Meet-student changed the title feat: add onEllipsis callback to Ellipsis component feat(Ellipsis): add onEllipsis callback to Ellipsis component Jun 24, 2025
Copy link

@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: 3

🔭 Outside diff range comments (2)
src/components/ellipsis/ellipsis.tsx (2)

43-52: 缺少 onEllipsis 属性的解构

在 props 解构中缺少 onEllipsis 属性,导致该回调无法在组件中使用。

  const {
    content,
    direction,
    rows,
    expandText,
    collapseText,
    stopPropagationForActionButtons,
    onContentClick,
    defaultExpanded,
+   onEllipsis,
  } = props

60-84: 缺少 onEllipsis 回调的调用

在展开和收起的点击处理函数中需要调用 onEllipsis 回调,否则该功能无法工作。

  const expandNode = expandText
    ? withStopPropagation(
        stopPropagationForActionButtons,
        <a
-         onClick={() => {
+         onClick={(e) => {
            setExpanded(true)
+           onEllipsis?.(true, e)
          }}
        >
          {expandText}
        </a>
      )
    : null

  const collapseNode = collapseText
    ? withStopPropagation(
        stopPropagationForActionButtons,
        <a
-         onClick={() => {
+         onClick={(e) => {
            setExpanded(false)
+           onEllipsis?.(false, e)
          }}
        >
          {collapseText}
        </a>
      )
    : null
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 38b028f and 370eb5c.

📒 Files selected for processing (5)
  • src/components/ellipsis/demos/demo1.tsx (1 hunks)
  • src/components/ellipsis/ellipsis.tsx (1 hunks)
  • src/components/ellipsis/index.en.md (1 hunks)
  • src/components/ellipsis/index.zh.md (1 hunks)
  • src/components/ellipsis/tests/ellipsis.test.tsx (1 hunks)
🔇 Additional comments (2)
src/components/ellipsis/ellipsis.tsx (1)

23-26: onEllipsis 属性定义正确

类型定义看起来合理,callback 接收 ellipsis 状态和鼠标事件参数。

src/components/ellipsis/tests/ellipsis.test.tsx (1)

106-124: 测试用例结构良好

测试用例正确验证了 onEllipsis 回调的预期行为。一旦组件实现中添加了回调调用,此测试应该能正常通过。

Copy link

pkg-pr-new bot commented Jun 24, 2025

npm i https://pkg.pr.new/ant-design/ant-design-mobile/antd-mobile@6893

commit: 13219d1

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.80%. Comparing base (38b028f) to head (13219d1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6893   +/-   ##
=======================================
  Coverage   92.79%   92.80%           
=======================================
  Files         336      336           
  Lines        7235     7237    +2     
  Branches     1818     1782   -36     
=======================================
+ Hits         6714     6716    +2     
- Misses        485      513   +28     
+ Partials       36        8   -28     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant