fix: enhance project context menu with theme submenu improvements#587
fix: enhance project context menu with theme submenu improvements#587webdevcody merged 2 commits intomainfrom
Conversation
- Added handlers for theme submenu to manage mouse enter/leave events with a delay, preventing premature closure. - Implemented dynamic positioning for the submenu to avoid viewport overflow, ensuring better visibility. - Updated styles to accommodate new positioning logic and added scroll functionality for theme selection. These changes improve user experience by making the theme selection process more intuitive and visually accessible.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds a hover-activated, viewport-aware theme submenu to project context and sidebar components, including memoized theme item components, dynamic positioning/maxHeight calculations, debounced hover close behavior, scrollable two-column layout, and new shared layout constants. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
Summary of ChangesHello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the user experience for theme selection within project context menus. By introducing intelligent hover delays, dynamic positioning that adapts to screen boundaries, and scrollable content, the changes ensure that the theme submenu is more robust, accessible, and intuitive to interact with, ultimately making theme management smoother for users. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances the project context menu's theme selection by adding a delay to the submenu's closing behavior and implementing dynamic positioning to prevent it from overflowing the viewport. The implementation is solid and improves the user experience. My review includes a few suggestions to improve code maintainability by replacing hardcoded 'magic numbers' with named constants, which will make the layout calculations clearer and easier to manage in the future.
apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx
Outdated
Show resolved
Hide resolved
apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx
Outdated
Show resolved
Hide resolved
apps/ui/src/components/layout/sidebar/components/project-selector-with-options.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx`:
- Around line 456-460: The computed inline maxHeight for the submenu can become
negative when the viewport is very small; update the calculation in the
project-context-menu component where submenuPosition.maxHeight is used (the div
with className "flex gap-2 overflow-y-auto scrollbar-styled") to clamp the value
to a minimum of 0 (e.g., use Math.max(0, submenuPosition.maxHeight -
THEME_SUBMENU_CONSTANTS.SUBMENU_HEADER_HEIGHT)) so the scroll area never
collapses to a negative height.
| <div | ||
| className="flex gap-2 overflow-y-auto scrollbar-styled" | ||
| style={{ | ||
| maxHeight: `${submenuPosition.maxHeight - THEME_SUBMENU_CONSTANTS.SUBMENU_HEADER_HEIGHT}px`, | ||
| }} |
There was a problem hiding this comment.
Clamp scroll maxHeight to avoid negative values in tiny viewports.
If the window height becomes smaller than the header + padding budget, this expression can go negative and collapse the scroll area. Consider clamping to 0 to keep layout stable.
🔧 Suggested fix
- style={{
- maxHeight: `${submenuPosition.maxHeight - THEME_SUBMENU_CONSTANTS.SUBMENU_HEADER_HEIGHT}px`,
- }}
+ style={{
+ maxHeight: `${Math.max(
+ 0,
+ submenuPosition.maxHeight - THEME_SUBMENU_CONSTANTS.SUBMENU_HEADER_HEIGHT
+ )}px`,
+ }}🤖 Prompt for AI Agents
In
`@apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx`
around lines 456 - 460, The computed inline maxHeight for the submenu can become
negative when the viewport is very small; update the calculation in the
project-context-menu component where submenuPosition.maxHeight is used (the div
with className "flex gap-2 overflow-y-auto scrollbar-styled") to clamp the value
to a minimum of 0 (e.g., use Math.max(0, submenuPosition.maxHeight -
THEME_SUBMENU_CONSTANTS.SUBMENU_HEADER_HEIGHT)) so the scroll area never
collapses to a negative height.
These changes improve user experience by making the theme selection process more intuitive and visually accessible.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.