From 73f417b38e84d0613b02fb098f5d94da80b67763 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Thu, 2 Jul 2026 12:28:03 -0700 Subject: [PATCH] fix(sidebar): keep hover title editor cursor stable --- .../sidebar/WorktreeCardMeta.interaction.test.tsx | 14 ++++++++++++++ .../sidebar/WorktreeTitleInlineRename.tsx | 13 +++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/sidebar/WorktreeCardMeta.interaction.test.tsx b/src/renderer/src/components/sidebar/WorktreeCardMeta.interaction.test.tsx index ddfa52a8b24..33132a25916 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardMeta.interaction.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardMeta.interaction.test.tsx @@ -213,15 +213,29 @@ describe('WorktreeCardDetailsHover interactions', () => { title?.dispatchEvent(new MouseEvent('dblclick', { bubbles: true, cancelable: true })) }) const input = container.querySelector('[data-worktree-title-rename-input]') + const sizingTitle = container.querySelector( + '[data-worktree-title-inline-rename="editing"] [aria-hidden="true"]' + ) expect(identityHeader?.className).toContain('cursor-text') expect(input).not.toBeNull() + expect(input?.className).toContain('cursor-text') expect(input?.className).toContain('select-text') + expect(sizingTitle?.className).toContain('pointer-events-none') + expect(input?.getAttribute('draggable')).toBe('false') expect(input?.className).toContain('bg-input/40') expect(input?.className).toContain('rounded-sm') expect(input?.className).toContain('selection:bg-[Highlight]') expect(input?.className).toContain('focus-visible:ring-[1px]') + const dragStart = new DragEvent('dragstart', { bubbles: true, cancelable: true }) + + act(() => { + input?.dispatchEvent(dragStart) + }) + + expect(dragStart.defaultPrevented).toBe(true) + act(() => { interactionMocks.onHoverOpenChange?.(false) }) diff --git a/src/renderer/src/components/sidebar/WorktreeTitleInlineRename.tsx b/src/renderer/src/components/sidebar/WorktreeTitleInlineRename.tsx index ea631e3f2c7..a6df5719200 100644 --- a/src/renderer/src/components/sidebar/WorktreeTitleInlineRename.tsx +++ b/src/renderer/src/components/sidebar/WorktreeTitleInlineRename.tsx @@ -180,6 +180,13 @@ export function WorktreeTitleInlineRename({ event.stopPropagation() }, []) + const stopInputDragEvent = useCallback((event: React.DragEvent) => { + // Why: selected rename text can become a drag target, which flips the cursor + // away from the I-beam while the title editor is active. + event.preventDefault() + event.stopPropagation() + }, []) + const startRename = useCallback( (event: React.MouseEvent) => { if (disabled) { @@ -263,7 +270,7 @@ export function WorktreeTitleInlineRename({ data-worktree-title-inline-rename="editing" >