fix: keep sidebar room row highlighted while options menu is open#38793
fix: keep sidebar room row highlighted while options menu is open#38793successbyte wants to merge 2 commits intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughThese changes introduce a unified pattern across sidebar item components to track menu open/close state via an onOpenChange callback. The pattern is propagated through the component hierarchy from RoomMenu to sidebar item variants (Condensed, Extended, Medium), enabling synchronized styling between the menu and its parent row element. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/client/sidebar/Item/Extended.tsx (1)
17-19:MenuPropsis duplicated acrossExtended.tsx,Condensed.tsx, andMedium.tsx.All three files define an identical
MenuPropstype. Extract it to a shared location (e.g. atypes.tsbarrel inapps/meteor/client/sidebar/Item/) so the contract is maintained in one place.♻️ Proposed refactor — shared type
Create
apps/meteor/client/sidebar/Item/types.ts:+export type MenuProps = { + onOpenChange?: (isOpen: boolean) => void; +};Then in each of the three files:
-type MenuProps = { - onOpenChange?: (isOpen: boolean) => void; -}; +import type { MenuProps } from './types';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/client/sidebar/Item/Extended.tsx` around lines 17 - 19, MenuProps is duplicated across Extended.tsx, Condensed.tsx, and Medium.tsx; extract it to a shared type file and import it from each component. Create apps/meteor/client/sidebar/Item/types.ts exporting type MenuProps = { onOpenChange?: (isOpen: boolean) => void }; then remove the local MenuProps declarations and update Extended.tsx, Condensed.tsx, and Medium.tsx to import { MenuProps } from './types'; ensure the imported symbol name matches usages (props and component typings) so builds and type checking continue to work.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/meteor/client/sidebar/Item/Condensed.tsxapps/meteor/client/sidebar/Item/Extended.tsxapps/meteor/client/sidebar/Item/Medium.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/meteor/client/sidebar/RoomMenu.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/client/sidebar/RoomMenu.tsxapps/meteor/client/sidebar/Item/Extended.tsxapps/meteor/client/sidebar/Item/Condensed.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/meteor/client/sidebar/Item/Medium.tsx
🔇 Additional comments (2)
apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx (1)
30-30: LGTM — forwarding pattern is well-structured.The
= {}default on the menu function parameter correctly handles zero-argument calls (theIconButtonplaceholder path), andonOpenChangeflows cleanly through toRoomMenu. TheReactElementreturn annotation is narrower than the declaredReactNodebut is assignable; no type issue.Also applies to: 124-141
apps/meteor/client/sidebar/Item/Extended.tsx (1)
64-71: Verifyis-hoveredCSS class is supported bySidebarV2Itemin fuselage.The
is-hoveredclass cannot be found in any local stylesheets and is only applied in Extended.tsx, Medium.tsx, and Condensed.tsx. SinceSidebarV2Itemis imported from the external@rocket.chat/fuselagepackage, the class must be defined there. If fuselage does not support this class name or uses a prop-based API instead (e.g.,hovered={menuOpen}), the highlight functionality will silently fail with no visual effect.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/meteor/client/sidebar/Item/Condensed.tsx`:
- Around line 5-7: The MenuProps type is duplicated between Condensed.tsx and
Extended.tsx; remove the duplicate by extracting MenuProps into a single shared
export (e.g., a sidebar/types or Item/types module) and import that shared type
into both Condensed.tsx and Extended.tsx, ensuring the exported symbol is named
MenuProps and the import sites update to reference it rather than redefining the
type.
- Around line 32-37: The component toggles an 'is-hovered' CSS class using
menuOpen, which mirrors the same incorrect dependency noted in Extended.tsx;
update the className logic to use the actual hover state/prop used by this
component (e.g., isHovered or the state updated by
handlePointerEnter/handleFocus) instead of menuOpen, and ensure the same fix is
applied to the second occurrence; locate SidebarV2Item and adjust the className
expression and any related state/prop names so the toggle relies on the correct
hover boolean that handlePointerEnter/handleFocus control.
In `@apps/meteor/client/sidebar/Item/Medium.tsx`:
- Around line 5-7: MenuProps is duplicated here; remove the local type in
Medium.tsx and import/reuse the single source of truth (the exported MenuProps)
used in Extended.tsx (or create a shared types module and export MenuProps from
there), then update Medium.tsx to reference the imported MenuProps instead of
redeclaring it so both Medium and Extended use the same type symbol.
- Around line 31-36: The component is conditionally adding the 'is-hovered' CSS
class using a loose truthy check; update the className assembly on SidebarV2Item
in Medium.tsx to only append 'is-hovered' when menuOpen is strictly true
(menuOpen === true) and ensure the existing className prop is normalized (handle
undefined) before joining; apply the same strict-check change to the other
occurrence referenced (line ~44) so both places consistently use the strict
boolean guard.
---
Nitpick comments:
In `@apps/meteor/client/sidebar/Item/Extended.tsx`:
- Around line 17-19: MenuProps is duplicated across Extended.tsx, Condensed.tsx,
and Medium.tsx; extract it to a shared type file and import it from each
component. Create apps/meteor/client/sidebar/Item/types.ts exporting type
MenuProps = { onOpenChange?: (isOpen: boolean) => void }; then remove the local
MenuProps declarations and update Extended.tsx, Condensed.tsx, and Medium.tsx to
import { MenuProps } from './types'; ensure the imported symbol name matches
usages (props and component typings) so builds and type checking continue to
work.
Proposed changes (including videos or screenshots)
This PR fixes a sidebar UX bug where the room/channel row highlight disappears after opening the options menu and moving the cursor into the menu.
Scope:
Video demo of the fix:
row-highlight-when-options-menu-open-fix.webm
Issue(s)
Closes #38792
Steps to test or reproduce
/home.Further comments
This is a minimal, targeted fix for the row highlight state while the options menu is open.
Summary by CodeRabbit