Skip to content

Fix docs language dropdown icon and navigation#1543

Merged
shrey150 merged 2 commits intomainfrom
shrey/fix-docs-language-dropdown
Jan 16, 2026
Merged

Fix docs language dropdown icon and navigation#1543
shrey150 merged 2 commits intomainfrom
shrey/fix-docs-language-dropdown

Conversation

@shrey150
Copy link
Copy Markdown
Contributor

@shrey150 shrey150 commented Jan 14, 2026

Fixes two issues with the docs language dropdown:

  1. Icon confusion: Changed all language dropdown icons to a generic code icon instead of language-specific logos (e.g., Python logo showing for every non-TypeScript option).
  2. Navigation sync: Clicking a language in the dropdown now navigates to the correct SDK page (e.g., selecting Go goes to /v3/sdk/go).

Also optimized performance by replacing all setTimeout calls with requestAnimationFrame for immediate, frame-synced updates and removed redundant duplicate function calls.

🤖 Generated with Claude Code


Summary by cubic

Fixes the docs language dropdown to use a generic code icon and ensures selecting a language navigates to the right docs page.

  • Bug Fixes

    • Set all dropdown icons to "code" in docs.json.
    • Selecting a language now routes to its docs page (e.g., Go → /v3/sdk/go) and correctly handles trailing slashes.
  • Refactors

    • Replaced setTimeout with requestAnimationFrame (onNextFrame) and MutationObserver for menu selection.
    • Removed duplicate delayed calls and initialized immediately.
    • Debounced DOM updates via rAF in observers and kept code block language in sync.

Written for commit a4ba7b8. Summary will update on new commits.

- Change all language dropdown icons to generic 'code' icon (no language-specific logos)
- Add explicit navigation when selecting a language in the dropdown (e.g., clicking Go navigates to /v3/sdk/go)
- Replace all setTimeout calls with requestAnimationFrame for immediate, frame-synced updates
- Remove redundant duplicate function calls at multiple delays (100ms, 500ms, 1000ms)
- Simplify initialization to execute immediately instead of waiting 500-1000ms

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 14, 2026

⚠️ No Changeset found

Latest commit: a4ba7b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jan 14, 2026

Greptile Summary

This PR fixes the docs language dropdown by standardizing all dropdown icons to a generic "code" icon and implementing proper navigation when selecting languages. It also adds Rust SDK as an external link option.

Key Changes:

  • Replaced language-specific icons (Python, TypeScript, Java, Go, Ruby logos) with generic "code" icon across all dropdown options
  • Added navigation logic that routes users to the correct SDK page when selecting a language (e.g., Python → /v3/sdk/python)
  • Added Rust to the dropdown as an external link that opens GitHub in a new tab
  • Optimized performance by replacing setTimeout calls with requestAnimationFrame via the onNextFrame helper for frame-synced updates
  • Improved code block menu selection by replacing recursive setTimeout polling with MutationObserver pattern
  • Fixed trailing slash handling in pathname comparison to prevent navigation issues

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations around navigation behavior
  • The changes are well-implemented with proper performance optimizations (replacing setTimeout with requestAnimationFrame) and clean separation of concerns (external vs internal languages). The navigation logic correctly handles trailing slashes and the code is defensive with try-catch blocks. Score is 4 instead of 5 because the navigation behavior might be unexpected for users already on a docs page - selecting a language will navigate them away from their current page to the SDK landing page, which may interrupt their workflow. However, this appears to be intentional based on the PR description.
  • No files require special attention

Important Files Changed

Filename Overview
packages/docs/docs.json Changed all language dropdown icons from language-specific logos to generic "code" icon and added Rust SDK with external GitHub link
packages/docs/language-selector.js Added navigation routing, external link handling for Rust, and replaced setTimeout with requestAnimationFrame for better performance

Sequence Diagram

sequenceDiagram
    participant User
    participant Dropdown
    participant JS as language-selector.js
    participant Browser
    
    User->>Dropdown: Click language option
    Dropdown->>JS: Click event captured
    
    alt External Language (Rust)
        JS->>Browser: Open GitHub in new tab
        Note over JS: No state change
    else Internal Language
        JS->>JS: Update currentSelectedLanguage
        JS->>JS: Update check indicator
        JS->>JS: Update version switcher visibility
        JS->>JS: Update SDK reference visibility
        JS->>Browser: Store selection in sessionStorage
        
        alt Already on target page
            JS->>JS: Update button text
            JS->>JS: Sync code block language
        else Different page
            JS->>Browser: Navigate to SDK page
        end
    end
    
    Browser->>JS: Page load/navigation
    JS->>Browser: Restore selection from sessionStorage
    JS->>JS: Update UI state
    JS->>JS: Sync code block language
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread packages/docs/language-selector.js Outdated
Comment thread packages/docs/language-selector.js
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-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.

2 issues found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/docs/language-selector.js">

<violation number="1" location="packages/docs/language-selector.js:47">
P2: The `waitForElement` function is defined but never used anywhere in the file. Consider removing this dead code or using it where appropriate (e.g., replacing manual polling loops like in `waitForCodeBlockMenuAndSelect`).</violation>

<violation number="2" location="packages/docs/language-selector.js:353">
P2: The pathname comparison using `endsWith(targetPath)` may fail when the current URL has a trailing slash (e.g., `/v3/sdk/python/` won't match `/v3/sdk/python`), causing unnecessary page reloads. Consider normalizing the pathname by removing trailing slashes before comparison: `window.location.pathname.replace(/\/$/, '').endsWith(targetPath)`</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/docs/language-selector.js Outdated
Comment thread packages/docs/language-selector.js Outdated
Normalize pathname by stripping trailing slashes before comparing
with target path in language selector navigation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread packages/docs/language-selector.js
Copy link
Copy Markdown
Member

@pirate pirate left a comment

Choose a reason for hiding this comment

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

requestAnimationFrame is a little extreme, thats every 16ms, maybe every 200ms is enough? or we can maybe de-register the check loop once the page is consistent?

otherwise LGTM

@shrey150
Copy link
Copy Markdown
Contributor Author

@greptileai

@shrey150 shrey150 force-pushed the shrey/fix-docs-language-dropdown branch from 3d49eb6 to a4ba7b8 Compare January 15, 2026 19:24
@shrey150 shrey150 requested a review from a team January 16, 2026 23:27
@shrey150 shrey150 merged commit f9702c3 into main Jan 16, 2026
10 checks 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.

3 participants