-
Notifications
You must be signed in to change notification settings - Fork 11
fix: focus on nav item when clicked #224
fix: focus on nav item when clicked #224
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🔍 Code Review Summary❗ Attention Required: This push has potential issues. 🚨 Overview
🚨 Critical Issuesperformance (1 issues)1. Use of setTimeout for scrolling can lead to performance issues.📁 File: packages/akiradocs/src/components/layout/Navigation.tsx 💡 Solution: Current Code: setTimeout(() =>{/* scrolling logic */}, 100);Suggested Code: requestAnimationFrame(() =>{/* scrolling logic */});Test Cases7 file need updates to their tests. Run
Useful Commands
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider implementing the following changes to improve the code.
| setTimeout(() => { | ||
| const viewport = itemRef.current?.closest('[data-radix-scroll-area-viewport]') as HTMLElement; | ||
| if (viewport) { | ||
| const itemRect = itemRef.current?.getBoundingClientRect(); | ||
| const viewportRect = viewport.getBoundingClientRect(); | ||
| const scrollOffset = (itemRect?.top ?? 0) - (viewportRect.top ?? 0) - (viewportRect.height / 2) + ((itemRect?.height ?? 0) / 2); | ||
|
|
||
| viewport.scrollTop += scrollOffset; | ||
| } | ||
| }, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Use of setTimeout for scrolling can lead to performance issues.
Solution: Consider using requestAnimationFrame instead of setTimeout for smoother animations.
!! Make sure the following suggestion is correct before committing it !!
| setTimeout(() => { | |
| const viewport = itemRef.current?.closest('[data-radix-scroll-area-viewport]') as HTMLElement; | |
| if (viewport) { | |
| const itemRect = itemRef.current?.getBoundingClientRect(); | |
| const viewportRect = viewport.getBoundingClientRect(); | |
| const scrollOffset = (itemRect?.top ?? 0) - (viewportRect.top ?? 0) - (viewportRect.height / 2) + ((itemRect?.height ?? 0) / 2); | |
| viewport.scrollTop += scrollOffset; | |
| } | |
| }, 100); | |
| requestAnimationFrame(() =>{/* scrolling logic */}); |
Manifest File Addition
Add a new
manifest.jsonfile that contains a list of all the compiled documentation files.manifest.jsonfile in thedocs/compileddirectory.The manifest file will make it easier to manage and navigate the compiled documentation, especially for large documentation sites with many pages.
Navigation Improvements
Enhance the navigation sidebar with better visual feedback and smooth scrolling.
These changes will improve the user experience by providing clearer visual cues for the current location and making it easier to navigate large documentation structures.
Miscellaneous Fixes and Improvements
Address various minor issues and enhance the overall documentation experience.
These changes will improve the code quality, maintainability, and overall stability of the AkiraDocs platform.
Original Description
## 🔍 DescriptionType
Checklist