Skip to content

fix(breadcrumbs): missing key for ellipsisItem#5239

Merged
jrgarciadev merged 2 commits into
canaryfrom
fix/eng-2218
Apr 28, 2025
Merged

fix(breadcrumbs): missing key for ellipsisItem#5239
jrgarciadev merged 2 commits into
canaryfrom
fix/eng-2218

Conversation

@wingkwong
Copy link
Copy Markdown
Member

@wingkwong wingkwong commented Apr 26, 2025

Closes #4973

📝 Description

Keys are specified for before & after collapse but not in ellipsisItem if users use renderEllipsis. Hence, this PR is to cater this case.

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes
    • Resolved an issue where the ellipsis item in breadcrumbs could cause rendering problems by ensuring it always has a proper key assigned. This improves stability and consistency in breadcrumb navigation displays.

@wingkwong wingkwong requested a review from jrgarciadev as a code owner April 26, 2025 08:28
@linear
Copy link
Copy Markdown

linear Bot commented Apr 26, 2025

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 26, 2025

🦋 Changeset detected

Latest commit: e1b1a71

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@heroui/breadcrumbs Patch
@heroui/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
heroui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2025 8:29am
heroui-sb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2025 8:29am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 26, 2025

Open in StackBlitz

@heroui/accordion

npm i https://pkg.pr.new/@heroui/accordion@5239

@heroui/alert

npm i https://pkg.pr.new/@heroui/alert@5239

@heroui/autocomplete

npm i https://pkg.pr.new/@heroui/autocomplete@5239

@heroui/avatar

npm i https://pkg.pr.new/@heroui/avatar@5239

@heroui/badge

npm i https://pkg.pr.new/@heroui/badge@5239

@heroui/breadcrumbs

npm i https://pkg.pr.new/@heroui/breadcrumbs@5239

@heroui/button

npm i https://pkg.pr.new/@heroui/button@5239

@heroui/calendar

npm i https://pkg.pr.new/@heroui/calendar@5239

@heroui/card

npm i https://pkg.pr.new/@heroui/card@5239

@heroui/checkbox

npm i https://pkg.pr.new/@heroui/checkbox@5239

@heroui/chip

npm i https://pkg.pr.new/@heroui/chip@5239

@heroui/code

npm i https://pkg.pr.new/@heroui/code@5239

@heroui/date-input

npm i https://pkg.pr.new/@heroui/date-input@5239

@heroui/date-picker

npm i https://pkg.pr.new/@heroui/date-picker@5239

@heroui/divider

npm i https://pkg.pr.new/@heroui/divider@5239

@heroui/drawer

npm i https://pkg.pr.new/@heroui/drawer@5239

@heroui/dropdown

npm i https://pkg.pr.new/@heroui/dropdown@5239

@heroui/form

npm i https://pkg.pr.new/@heroui/form@5239

@heroui/image

npm i https://pkg.pr.new/@heroui/image@5239

@heroui/input

npm i https://pkg.pr.new/@heroui/input@5239

@heroui/input-otp

npm i https://pkg.pr.new/@heroui/input-otp@5239

@heroui/kbd

npm i https://pkg.pr.new/@heroui/kbd@5239

@heroui/link

npm i https://pkg.pr.new/@heroui/link@5239

@heroui/listbox

npm i https://pkg.pr.new/@heroui/listbox@5239

@heroui/menu

npm i https://pkg.pr.new/@heroui/menu@5239

@heroui/modal

npm i https://pkg.pr.new/@heroui/modal@5239

@heroui/navbar

npm i https://pkg.pr.new/@heroui/navbar@5239

@heroui/number-input

npm i https://pkg.pr.new/@heroui/number-input@5239

@heroui/pagination

npm i https://pkg.pr.new/@heroui/pagination@5239

@heroui/popover

npm i https://pkg.pr.new/@heroui/popover@5239

@heroui/progress

npm i https://pkg.pr.new/@heroui/progress@5239

@heroui/radio

npm i https://pkg.pr.new/@heroui/radio@5239

@heroui/ripple

npm i https://pkg.pr.new/@heroui/ripple@5239

@heroui/scroll-shadow

npm i https://pkg.pr.new/@heroui/scroll-shadow@5239

@heroui/select

npm i https://pkg.pr.new/@heroui/select@5239

@heroui/skeleton

npm i https://pkg.pr.new/@heroui/skeleton@5239

@heroui/slider

npm i https://pkg.pr.new/@heroui/slider@5239

@heroui/snippet

npm i https://pkg.pr.new/@heroui/snippet@5239

@heroui/spacer

npm i https://pkg.pr.new/@heroui/spacer@5239

@heroui/spinner

npm i https://pkg.pr.new/@heroui/spinner@5239

@heroui/switch

npm i https://pkg.pr.new/@heroui/switch@5239

@heroui/table

npm i https://pkg.pr.new/@heroui/table@5239

@heroui/tabs

npm i https://pkg.pr.new/@heroui/tabs@5239

@heroui/toast

npm i https://pkg.pr.new/@heroui/toast@5239

@heroui/tooltip

npm i https://pkg.pr.new/@heroui/tooltip@5239

@heroui/user

npm i https://pkg.pr.new/@heroui/user@5239

@heroui/react

npm i https://pkg.pr.new/@heroui/react@5239

@heroui/system

npm i https://pkg.pr.new/@heroui/system@5239

@heroui/system-rsc

npm i https://pkg.pr.new/@heroui/system-rsc@5239

@heroui/theme

npm i https://pkg.pr.new/@heroui/theme@5239

@heroui/use-aria-accordion

npm i https://pkg.pr.new/@heroui/use-aria-accordion@5239

@heroui/use-aria-accordion-item

npm i https://pkg.pr.new/@heroui/use-aria-accordion-item@5239

@heroui/use-aria-button

npm i https://pkg.pr.new/@heroui/use-aria-button@5239

@heroui/use-aria-link

npm i https://pkg.pr.new/@heroui/use-aria-link@5239

@heroui/use-aria-modal-overlay

npm i https://pkg.pr.new/@heroui/use-aria-modal-overlay@5239

@heroui/use-aria-multiselect

npm i https://pkg.pr.new/@heroui/use-aria-multiselect@5239

@heroui/use-callback-ref

npm i https://pkg.pr.new/@heroui/use-callback-ref@5239

@heroui/use-clipboard

npm i https://pkg.pr.new/@heroui/use-clipboard@5239

@heroui/use-data-scroll-overflow

npm i https://pkg.pr.new/@heroui/use-data-scroll-overflow@5239

@heroui/use-disclosure

npm i https://pkg.pr.new/@heroui/use-disclosure@5239

@heroui/use-draggable

npm i https://pkg.pr.new/@heroui/use-draggable@5239

@heroui/use-image

npm i https://pkg.pr.new/@heroui/use-image@5239

@heroui/use-infinite-scroll

npm i https://pkg.pr.new/@heroui/use-infinite-scroll@5239

@heroui/use-intersection-observer

npm i https://pkg.pr.new/@heroui/use-intersection-observer@5239

@heroui/use-is-mobile

npm i https://pkg.pr.new/@heroui/use-is-mobile@5239

@heroui/use-is-mounted

npm i https://pkg.pr.new/@heroui/use-is-mounted@5239

@heroui/use-measure

npm i https://pkg.pr.new/@heroui/use-measure@5239

@heroui/use-pagination

npm i https://pkg.pr.new/@heroui/use-pagination@5239

@heroui/use-real-shape

npm i https://pkg.pr.new/@heroui/use-real-shape@5239

@heroui/use-ref-state

npm i https://pkg.pr.new/@heroui/use-ref-state@5239

@heroui/use-resize

npm i https://pkg.pr.new/@heroui/use-resize@5239

@heroui/use-safe-layout-effect

npm i https://pkg.pr.new/@heroui/use-safe-layout-effect@5239

@heroui/use-scroll-position

npm i https://pkg.pr.new/@heroui/use-scroll-position@5239

@heroui/use-ssr

npm i https://pkg.pr.new/@heroui/use-ssr@5239

@heroui/use-theme

npm i https://pkg.pr.new/@heroui/use-theme@5239

@heroui/use-update-effect

npm i https://pkg.pr.new/@heroui/use-update-effect@5239

@heroui/aria-utils

npm i https://pkg.pr.new/@heroui/aria-utils@5239

@heroui/dom-animation

npm i https://pkg.pr.new/@heroui/dom-animation@5239

@heroui/react-rsc-utils

npm i https://pkg.pr.new/@heroui/react-rsc-utils@5239

@heroui/framer-utils

npm i https://pkg.pr.new/@heroui/framer-utils@5239

@heroui/react-utils

npm i https://pkg.pr.new/@heroui/react-utils@5239

@heroui/shared-icons

npm i https://pkg.pr.new/@heroui/shared-icons@5239

@heroui/shared-utils

npm i https://pkg.pr.new/@heroui/shared-utils@5239

@heroui/stories-utils

npm i https://pkg.pr.new/@heroui/stories-utils@5239

@heroui/test-utils

npm i https://pkg.pr.new/@heroui/test-utils@5239

commit: e1b1a71

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2025

Walkthrough

A patch was applied to the Breadcrumbs component in the @heroui/breadcrumbs package to address an issue with the ellipsisItem lacking a proper React key. The change ensures that the ellipsisItem is checked for validity as a React element, and if valid, it is cloned with an explicit key before being rendered. This update is intended to resolve key-related warnings during rendering, particularly when using custom ellipsis items in breadcrumbs.

Changes

File(s) Change Summary
.changeset/modern-balloons-wash.md Added a changeset describing the patch to fix missing key on ellipsisItem in breadcrumbs.
packages/components/breadcrumbs/src/breadcrumbs.tsx Updated logic to check if ellipsisItem is a valid React element and clone it with a key if so.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Breadcrumbs
    participant React

    User->>Breadcrumbs: Render with custom renderEllipsis
    Breadcrumbs->>Breadcrumbs: Build breadcrumb items with useMemo
    Breadcrumbs->>Breadcrumbs: Check if ellipsisItem is valid React element
    alt ellipsisItem is valid
        Breadcrumbs->>Breadcrumbs: Clone ellipsisItem with key="ellipsis-item"
    else ellipsisItem is not valid
        Breadcrumbs->>Breadcrumbs: Skip cloning
    end
    Breadcrumbs->>React: Render breadcrumb items (with correct keys)
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure items provided to renderEllipsis retain original key from BreadcrumbItem, preventing duplicate key warnings (#4973)

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efda62c and e1b1a71.

📒 Files selected for processing (2)
  • .changeset/modern-balloons-wash.md (1 hunks)
  • packages/components/breadcrumbs/src/breadcrumbs.tsx (2 hunks)
🔇 Additional comments (3)
packages/components/breadcrumbs/src/breadcrumbs.tsx (2)

1-1: Good addition of the isValidElement import!

This import is necessary to support the key addition logic for the ellipsisItem.


93-93: Excellent fix for the missing key issue.

This change elegantly handles two potential issues:

  1. It safely checks if ellipsisItem is a valid React element before attempting to clone it
  2. It adds the missing key to the ellipsisItem when custom renderEllipsis functions are used

This will prevent React key warnings and improve rendering performance by giving React a stable identity for the ellipsis item.

.changeset/modern-balloons-wash.md (1)

1-5: Appropriate changeset for this bugfix.

The changeset correctly identifies this as a patch-level change and provides a clear description that references the issue being fixed. This will help users understand what was addressed when reading the changelog.

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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.

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.

@jrgarciadev jrgarciadev merged commit a61f57b into canary Apr 28, 2025
10 checks passed
@jrgarciadev jrgarciadev deleted the fix/eng-2218 branch April 28, 2025 21:40
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.

[BUG] - Duplicate Key Warning in Breadcrumbs Component When Using renderEllipsis

2 participants