Fix docs language dropdown icon and navigation#1543
Conversation
- 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>
|
Greptile SummaryThis 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:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
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
|
There was a problem hiding this comment.
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.
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>
pirate
left a comment
There was a problem hiding this comment.
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
3d49eb6 to
a4ba7b8
Compare
Fixes two issues with the docs language dropdown:
codeicon instead of language-specific logos (e.g., Python logo showing for every non-TypeScript option)./v3/sdk/go).Also optimized performance by replacing all
setTimeoutcalls withrequestAnimationFramefor 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
Refactors
Written for commit a4ba7b8. Summary will update on new commits.