Skip to content

fix(web): calculate using the filtered breadcrumbs length#884

Merged
shuqinzhao merged 2 commits intorelease/v0.3.0from
fix/v0.3.0_zy
Apr 14, 2026
Merged

fix(web): calculate using the filtered breadcrumbs length#884
shuqinzhao merged 2 commits intorelease/v0.3.0from
fix/v0.3.0_zy

Conversation

@shuqinzhao
Copy link
Copy Markdown
Collaborator

@shuqinzhao shuqinzhao commented Apr 14, 2026

Summary by Sourcery

错误修复:

  • 确保最后一个面包屑项是基于已过滤的非分组面包屑计算得出,这样就能对真正的最后一项正确地禁用导航。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Ensure the last breadcrumb item is computed based on the filtered non-group breadcrumbs so that navigation is correctly disabled for the actual final item.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 14, 2026

评审者指南(在小型 PR 上折叠)

评审者指南

调整面包屑渲染逻辑,使最后一项的检测基于过滤后的(非 group 类型)面包屑列表,而不是原始数组,从而在存在 group 类型面包屑时避免错误的“最后一项”行为。

使用过滤后最后一项检测的面包屑渲染时序图

sequenceDiagram
  actor User
  participant AppHeader
  participant formatBreadcrumbNames
  participant Tooltip

  User->>AppHeader: render
  AppHeader->>formatBreadcrumbNames: call with breadcrumbs
  formatBreadcrumbNames->>formatBreadcrumbNames: filtered = breadcrumbs.filter(type != group)
  formatBreadcrumbNames->>formatBreadcrumbNames: iterate filtered with index
  formatBreadcrumbNames->>Tooltip: create title with label
  Tooltip-->>formatBreadcrumbNames: Tooltip element
  formatBreadcrumbNames-->>AppHeader: breadcrumb items with isLast = (index == filtered.length - 1)
  AppHeader-->>User: breadcrumbs rendered with correct last item behavior
Loading

文件级改动

变更 详情 文件
修复最后一个面包屑的检测逻辑,使其基于过滤后的面包屑列表,而不是完整的面包屑数组。
  • 在渲染前引入一个本地的过滤后面包屑数组,排除 typegroup 的项。
  • 在渲染面包屑项时,在 map 回调中使用该过滤后的数组。
  • 使用 filtered.length - 1 来计算 isLast,从而在存在 group 项时正确识别最后一个可点击的面包屑。
web/src/components/Header/index.tsx

技巧与命令

与 Sourcery 交互

  • 触发新的评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 通过回复某条评审评论,要求 Sourcery 从该评论创建一个 issue。你也可以直接回复该评审评论 @sourcery-ai issue 来从中创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成评审者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 评审。特别适用于你想从一次全新的评审开始的情况——别忘了再评论 @sourcery-ai review 来触发新的评审!

自定义你的体验

访问你的 控制面板 以:

  • 启用或禁用评审功能,如 Sourcery 生成的 pull request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审说明。
  • 调整其他评审设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts breadcrumb rendering logic so last-item detection uses the filtered (non-group) breadcrumb list rather than the original array, preventing incorrect last-item behavior when group-type breadcrumbs are present.

Sequence diagram for breadcrumb rendering with filtered last-item detection

sequenceDiagram
  actor User
  participant AppHeader
  participant formatBreadcrumbNames
  participant Tooltip

  User->>AppHeader: render
  AppHeader->>formatBreadcrumbNames: call with breadcrumbs
  formatBreadcrumbNames->>formatBreadcrumbNames: filtered = breadcrumbs.filter(type != group)
  formatBreadcrumbNames->>formatBreadcrumbNames: iterate filtered with index
  formatBreadcrumbNames->>Tooltip: create title with label
  Tooltip-->>formatBreadcrumbNames: Tooltip element
  formatBreadcrumbNames-->>AppHeader: breadcrumb items with isLast = (index == filtered.length - 1)
  AppHeader-->>User: breadcrumbs rendered with correct last item behavior
Loading

File-Level Changes

Change Details Files
Fix last breadcrumb detection to be based on the filtered breadcrumb list instead of the full breadcrumbs array.
  • Introduce a local filtered array of breadcrumbs that excludes items with type 'group' before mapping for rendering.
  • Use the filtered array in the map callback for rendering breadcrumb items.
  • Compute isLast using filtered.length - 1 so that the last clickable breadcrumb is correctly identified when group items are present.
web/src/components/Header/index.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

嗨——我已经审查了你的更改,看起来非常棒!


Sourcery 对开源项目是免费的——如果你觉得我们的审查有帮助,请考虑分享给更多人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的审查。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@shuqinzhao shuqinzhao merged commit aa683ef into release/v0.3.0 Apr 14, 2026
1 check 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.

1 participant