Skip to content

fix(ui): prevent rename input from losing focus when triggered via context menu#1138

Merged
arnestrickmann merged 1 commit intomainfrom
emdash/renaming-fails-29t
Feb 27, 2026
Merged

fix(ui): prevent rename input from losing focus when triggered via context menu#1138
arnestrickmann merged 1 commit intomainfrom
emdash/renaming-fails-29t

Conversation

@arnestrickmann
Copy link
Contributor

Summary

  • Fixes task rename failing when initiated from the right-click context menu
  • Adds a blur guard mechanism to prevent the Radix context menu close animation (~150ms) and focus restoration from stealing focus away from the rename input
  • The onBlur handler now checks the guard ref and re-focuses the input if the blur was caused by the context menu dismissal rather than a genuine focus loss
  • Also adds onMouseDown={stopPropagation} to prevent click events on the input from bubbling up to parent handlers

Fixes GEN-428

@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Building Building Preview, Comment Feb 27, 2026 0:57am

Request Review

@greptile-apps
Copy link

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Implements a blur guard mechanism to fix task rename failing when triggered from the right-click context menu. The solution prevents the Radix context menu's close animation (~150ms) and focus restoration from stealing focus away from the rename input.

Changes:

  • Added blurGuardRef and blurGuardTimerRef to track and manage focus state
  • Modified handleStartEdit to activate guard for 300ms when editing begins
  • Updated onBlur handler to detect and recover from context menu-induced blur events by re-focusing the input
  • Added onMouseDown={stopPropagation} to prevent click events from bubbling to parent handlers
  • Properly disables guard in handleCancelEdit and handleConfirmEdit

Issues:

  • Missing timer cleanup on component unmount (minor best practice issue)

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it fixes a specific UI bug without affecting other functionality
  • The blur guard implementation is well-designed and correctly handles the focus issue. The logic properly accounts for edge cases (Enter/Escape keys, confirm/cancel actions). The only issue is a minor best practice violation (missing timer cleanup on unmount), which won't cause functional problems but should be addressed for consistency with the codebase.
  • No files require special attention - the change is focused and well-contained

Important Files Changed

Filename Overview
src/renderer/components/TaskItem.tsx Added blur guard mechanism with timer to prevent context menu from stealing focus from rename input. Missing timer cleanup on unmount.

Last reviewed commit: 213d9b9

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

const inputRef = useRef<HTMLInputElement>(null);
const isSubmittingRef = useRef(false);
const blurGuardRef = useRef(false);
const blurGuardTimerRef = useRef<ReturnType<typeof setTimeout>>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing timer cleanup on component unmount (see GitHubIssuePreviewTooltip.tsx:94-97 for example). Add:

Suggested change
const blurGuardTimerRef = useRef<ReturnType<typeof setTimeout>>();
const blurGuardTimerRef = useRef<ReturnType<typeof setTimeout>>();
useEffect(() => {
return () => {
clearTimeout(blurGuardTimerRef.current);
};
}, []);

@arnestrickmann arnestrickmann merged commit a123534 into main Feb 27, 2026
5 checks passed
@arnestrickmann arnestrickmann deleted the emdash/renaming-fails-29t branch February 27, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant