Skip to content

fix(kno-11552): remove undefined breadcrumbs from docs#1344

Open
cellomatt wants to merge 1 commit intomainfrom
cursor/KNO-11552-docs-breadcrumbs-undefined-f07c
Open

fix(kno-11552): remove undefined breadcrumbs from docs#1344
cellomatt wants to merge 1 commit intomainfrom
cursor/KNO-11552-docs-breadcrumbs-undefined-f07c

Conversation

@cellomatt
Copy link
Member

@cellomatt cellomatt commented Mar 10, 2026

Description

This PR resolves the issue of "undefined" appearing in breadcrumbs on certain nested documentation pages, particularly within the /in-app-ui section.

Why:
The problem stemmed from two main issues:

  1. Incorrect Breadcrumb Generation: The getInAppSidebar function in lib/content.ts was unconditionally generating breadcrumb items, leading to undefined values being converted to the string "undefined" when a matching section or page was not found.
  2. State Synchronization Timing Issue: In layouts/InAppUILayout.tsx, the selectedSdk React state was not reliably syncing with the Next.js router's path after client-side hydration. This caused the breadcrumb logic to use an outdated SDK context, resulting in failed lookups.

How:

  1. lib/content.ts: The getInAppSidebar function now conditionally adds breadcrumb items only when valid slug and title properties exist for the section or page.
  2. layouts/InAppUILayout.tsx:
    • A useEffect hook was added to synchronize the selectedSdk state with the SDK value extracted from the URL path, ensuring the correct SDK context is always available.
    • The breadcrumb computation logic was updated to prioritize the SDK derived directly from the URL path (validSdkFromPath) over the selectedSdk state, mitigating timing issues.
    • The InAppSidebar component now uses an effectiveSdk prop to ensure the dropdown consistently reflects the current page's SDK.

Todos

  • None

Tasks

Screenshots

Old:
image

New:
image

Linear Issue: KNO-11552

Open in Web Open in Cursor 

- In getInAppSidebar, only add section/page breadcrumbs when they exist
  to avoid template literals converting undefined to 'undefined' strings
- Add useEffect to sync selectedSdk when router paths change after hydration
- Derive effectiveSdk directly from URL path for immediate breadcrumb rendering
- Pass effectiveSdk to InAppSidebar for consistent dropdown display

Fixes pages like /in-app-ui/android/sdk/overview and /in-app-ui/android/components
that were showing 'undefined' and 'undefinedundefined' in breadcrumbs.

Resolves KNO-11552

Co-authored-by: Matt Kufchak <matt.kufchak@gmail.com>
@cursor
Copy link

cursor bot commented Mar 10, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@linear
Copy link

linear bot commented Mar 10, 2026

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 10, 2026 4:55pm

Request Review

@cellomatt cellomatt requested a review from MikeCarbone March 10, 2026 17:19
@cellomatt cellomatt marked this pull request as ready for review March 10, 2026 17:19
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Risk HIGH: Fixes "undefined" appearing in breadcrumbs on nested in-app UI pages by adding conditional breadcrumb generation and syncing SDK state with the URL path.

Reasons

  • layouts/InAppUILayout.tsx (a .tsx file in layouts/) is modified — triggers HIGH risk per classification rules
  • lib/content.ts (a .ts file in lib/) is modified — triggers HIGH risk per classification rules
  • Changes affect breadcrumb generation logic used across all in-app UI pages, making this a shared/reusable code path
  • A new useEffect hook is introduced in the layout component, altering React lifecycle behavior
  • State derivation logic is changed (new effectiveSdk variable replaces direct selectedSdk usage), which could affect rendering across multiple pages

Notes

  • Verify the useEffect dependency array ([paths, selectedSdk]) does not cause unnecessary re-renders or infinite loops — selectedSdk is set inside the effect and is also a dependency
  • Confirm breadcrumbs render correctly on all in-app UI nested pages (e.g., /in-app-ui/react/overview, /in-app-ui/react/feed/components) after the conditional push logic in lib/content.ts
  • Check that the effectiveSdk derivation handles edge cases such as direct navigation, browser back/forward, and initial SSR hydration
  • The Vercel preview deployment is live — recommend manually testing breadcrumb rendering on several nested paths before merging
Open in Web View Automation 

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

) {
setSelectedSdk(sdkFromPath);
}
}, [paths, selectedSdk]);
Copy link

Choose a reason for hiding this comment

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

useEffect reverts SDK state during SDK switch

Medium Severity

The useEffect includes selectedSdk in its dependency array, causing it to fire when handleSdkChange updates state. Since router.push() is async, the URL path still reflects the old SDK at that point, so sdkFromPath !== selectedSdk evaluates to true and the effect calls setSelectedSdk(sdkFromPath), reverting the user's selection. Combined with effectiveSdk always prioritizing the path-derived SDK, the dropdown visibly snaps back to the previous SDK until the route transition completes, causing unnecessary re-renders and a brief UI flicker.

Additional Locations (1)
Fix in Cursor Fix in Web

@cellomatt
Copy link
Member Author

This is a simple fix that doesn't include nested sections (like SDK and UI Components), but I think that ok and it removes the erroneous undefinedundefined that displays currently

@cellomatt cellomatt changed the title Docs breadcrumbs undefined fix(kno-11552): remove undefined breadcrumbs from docs Mar 10, 2026
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.

2 participants