From 951f58751c152fbbb3f8b3ce3c814c06c061de18 Mon Sep 17 00:00:00 2001 From: Alex Navarro <78754189+navarrotech@users.noreply.github.com> Date: Fri, 29 May 2026 09:04:35 -0600 Subject: [PATCH] fix(sidebar): keep session rename input visible while editing (#781) The rename input shares a parent div that uses `group-hover:opacity-100`, so moving the cursor off the row visually hid the input mid-edit. While editing, force the action panel to `opacity-100` and dismiss it via an outside-click listener instead of mouseleave. Also hide the relative-time badge so it does not overlap the input. --- .../view/subcomponents/SidebarSessionItem.tsx | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx b/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx index cb22a7a2..209a9832 100644 --- a/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx +++ b/src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from 'react'; import { Check, Edit2, Trash2, X } from 'lucide-react'; import type { TFunction } from 'i18next'; @@ -76,7 +77,28 @@ export default function SidebarSessionItem({ }: SidebarSessionItemProps) { const sessionView = createSessionViewModel(session, currentTime, t); const isSelected = selectedSession?.id === session.id; + const isEditing = editingSession === session.id; const compactSessionAge = formatCompactSessionAge(sessionView.sessionTime, currentTime); + const editingContainerRef = useRef(null); + + // The rename panel sits inside a group-hover opacity wrapper, so leaving the row + // would visually hide it. While editing, dismiss only when the user clicks outside + // the panel (matches Escape / cancel-button behaviour). + useEffect(() => { + if (!isEditing) { + return; + } + + const handlePointerDown = (event: MouseEvent) => { + const container = editingContainerRef.current; + if (container && !container.contains(event.target as Node)) { + onCancelEditingSession(); + } + }; + + document.addEventListener('mousedown', handlePointerDown); + return () => document.removeEventListener('mousedown', handlePointerDown); + }, [isEditing, onCancelEditingSession]); // Sessions are owned by a project identified by `projectId` (DB primary key) // after the projectName → projectId migration. @@ -174,7 +196,12 @@ export default function SidebarSessionItem({
{sessionView.sessionName}
{compactSessionAge && ( - + {compactSessionAge} )} @@ -186,8 +213,14 @@ export default function SidebarSessionItem({
-
- {editingSession === session.id ? ( +
+ {isEditing ? ( <>